# Test fix for ticket:238. Default InitExprs not allowed in structs # struct-init.cobra(8): error: "St.Name": cannot have instance field initializers in structs (C#) # struct-init.cobra(19): error: "St1.X": cannot have instance field initializers in structs (C#) class XX pass struct St var name as String var n as int cue init(name as String, n as int) .name = name .n = n # def toString as String is override # return 'St(name=[.name], n=[.n])' struct St1 var x as XX var n as int cue init(x as XX, n as int) .x = x .n = n # def toString as String is override # return 'St(x=[.x], n=[.n])' class Entry def main is shared x = St('xxx', 10) assert x.name == 'xxx' and x.n == 10 xx = XX() x1 = St1(xx, 11) assert x1.x == xx and x1.n == 11 # declare only and pack/unpack members explicitly xa as St #pack xa.name = 'aaa' xa.n = 12 #unpack xa_name = xa.name xa_n = xa.n assert xa_name == 'aaa' and xa_n == 12