Ticket #238 (closed defect: fixed)
Bad Code gen for structs containing Strings
Reported by: | hopscc | Owned by: | Chuck |
---|---|---|---|
Priority: | medium | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
struct St var name as String var n as int cue init(name as String, n as int) .name = name .n = n class T def main is shared x = St('xxx', 10)
gives
c:\home\hops\src\cobra\Tst\struct.cobra(2): error: "St.Name": cannot have instance field initializers in structs (C#) Compilation failed - 1 error, 0 warnings
(Error from C# compiler)
offending lines in gen C# source
#line 1 public struct St{ #line 1 #line 1 int _ih_invariantGuard; #line 1 #line 2 public System.String Name = null; #line 3 public System.Int32 N; #line 3 } // struct St
Same for any ref class not just Strings.
Looks like for code gen in structs explicit (Null) initialisation of refclass members should be elided
Attachments
Change History
Note: See
TracTickets for help on using
tickets.