Wiki

Ticket #158 (closed defect: fixed)

Opened 15 years ago

Last modified 15 years ago

numeric for expr broken

Reported by: Chuck Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

This test case results in bogus errors due, at least in part, to bad C# code gen:

class X

        def main is shared
                n = 5
                stuff = for i in n get .thing(i)
                trace stuff

        def thing(i as int) as Object is shared
                return i*i

Attachments

numForBroke.patch Download (4.4 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by hopscc

  • owner set to hopscc
  • status changed from new to assigned

Clarification.
This works correctly when the method called takes an int and returns one

def thing(i as int) as int is shared
    return i*i

It fails in all other cases with an error message from the C# compiler
like:

NumFor.cobra(10) error: The best overloaded method match for Cobra.Lang_ert_9ab85f7adadc1e32eda903e79ed62744.CobraImp.For<int,string>(int, int, int, Cobra.Lang_ert_9ab85f7adadc1e32eda903e79ed62744.CobraImp.ForGet<int,int>)" has some invalid arguments (C#)
NumFor.cobra(10): error: Argument "4": cannot convert from "anonymous method" to "Cobra.Lang_ert_9ab85f7adadc1e32eda903e79ed62744.CobraImp.ForGet<int,int>" (C#)

This "Cobra.Lang_ert_9ab85f7adadc1e32eda903e79ed62744" indicates the C# compiler is complaining about a mismatch against a generic method in the csharp RTL code. (BackEndClr/Native.cs).

It appears the generic method may be unnecessarily restrictive.

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

  • owner changed from hopscc to Chuck

patch, test and relnote.

Changed 15 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Thanks. Patch applied in changeset:2213

Note that it wasn't just methods that caused the problem. Any expression for the get that had a non-int type would cause the problem. So I added a little more test code and dropped "-method" from the filename.

Note: See TracTickets for help on using tickets.