initializer won't work with enum values
Posted: Sun Oct 26, 2008 8:57 am
It seems (to me) that initializer syntax has a problem with litteral enum values, see example bellow:
giving me
Is it expected behaviour?
Thanks
EDIT: also, initializers won't work for member declaration, only for local variables, c# 3 to support this.
enum StyleType
Undefined
OldFashioned
Hype
class Model
var _style
pro style from var
class Program
def main is shared
hypeStyle = StyleType(Hype)
model = Model(style=StyleType(Hype)) #wont compile
model = Model(style=hypeStyle) #compile
giving me
- Code: Select all
fail.cobra(14): error: COBRA INTERNAL ERROR / AssertException / ; sourceSite = C:\home\dev\src\dotnet\projects\cobralanguage\Source\Node.cobra:592 in Node._transformTo for object PostCallExpr-sh(12214, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=false, token=Token(OPEN_CALL, 'StyleType(', 'StyleType', ln 14, col 23, fail.cobra), type=EnumDecl-mi(12199, name=StyleType, didStartBindInh=true, didBindInh=true, didStartBindInt=true, didBindInt=true, didStartBindImp=true, didBindImp=true, token=Token(ENUM, 'enum', 'enum', ln 1, col 1, fail.cobra), 12199), 12214); info = 'superNode=PostCallExpr-sh(12217, didBindInh=false, didBindInt=false, didStartBindImp=true, isBindingImp=true, didBindImp=false, token=Token(OPEN_CALL, 'Model(', 'Model', ln 14, col 11, fail.cobra), type=nil, 12217), newNode=EnumCallExpr-sh(39103, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=true, token=Token(OPEN_CALL, 'StyleType(', 'StyleType', ln 14, col 23, fail.cobra), type=EnumDecl-mi(12199, name=StyleType, didStartBindInh=true, didBindInh=true, didStartBindInt=true, didBindInt=true, didStartBindImp=true, didBindImp=true, token=Token(ENUM, 'enum', 'enum', ln 1, col 1, fail.cobra), 12199), 39103)'; this = PostCallExpr-de(12214, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=false, token=Token(OPEN_CALL, 'StyleType(', 'StyleType', ln 14, col 23, fail.cobra), type=EnumDecl-mi(12199, name=StyleType, didStartBindInh=true, didBindInh=true, didStartBindInt=true, didBindInt=true, didStartBindImp=true, didBindImp=true, token=Token(ENUM, 'enum', 'enum', ln 1, col 1, fail.cobra), 12199), expr=IdentifierExpr-sh(12213, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=true, token=Token(OPEN_CALL, 'StyleType(', 'StyleType', ln 14, col 23, fail.cobra), name=StyleType, type=Class-mi(1382, name=Type, didStartBindInh=true, didBindInh=true, didStartBindInt=true, didBindInt=true, didBindImp=false, token=Token((EMPTY), '', nil, ln 1, col 1, (empty)), didBindInh=true, isGeneric=false, isGenericDef=false, needsConstruction=false, 1382), definition=EnumDecl-mi(12199, name=StyleType, didStartBindInh=true, didBindInh=true, didStartBindInt=true, didBindInt=true, didStartBindImp=true, didBindImp=true, token=Token(ENUM, 'enum', 'enum', ln 1, col 1, fail.cobra), 12199), 12213), args=['IdentifierExpr'-'sh'(12212, 'didBindInh'=false, 'didBindInt'=false, 'didBindImp'=false, 'token'=''Token'('ID', ''Hype'', ''Hype'', ln 14, col 33, 'fail.cobra')', 'name'='Hype', 'type'=nil, 'definition'=''EnumMember'-'mi'(12198, 'name'='Hype', 'didBindInh'=false, 'didBindInt'=false, 'didBindImp'=false, 'token'=''Token'('ID', ''Hype'', ''Hype'', ln 4, col 2, 'fail.cobra')', 'value'=nil, 12198)', 12212)], hasKeywordArg=false, isForAttribute=false, 12214); didReplace = false;
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
Is it expected behaviour?
Thanks
EDIT: also, initializers won't work for member declaration, only for local variables, c# 3 to support this.