I'm at a loss as to how to explain what's going on here, but I think this is a bug. Consider the following code.
Code: Select all
type firstType
dim as uinteger<64> x
'Remove to fix #1
declare operator cast() as uinteger<64>
end type
'Also remove to fix #1
operator firstType.cast() as uinteger<64>
return this.x
end operator
type mytype
dim x as firstType
dim y as integer
end type
'OK
dim comp as firstType
dim test as mytype = (comp, 1)
'NOT OK?
dim comp2(0) as firstType
'dim tempType as firstType = comp2(0) 'This can be used in place of comp2(0) below as a different fix #2
dim test2 as mytype = (comp2(0), 1) '<-- Too many expressions error
1) Remove the cast to uinteger<64> in the type "firstType" (it could be any cast to any integer type and the bug still manifests btw)
2) First assign an intermediate variable of type "firstType" to "comp2(0), and use that variable instead
The default constructor of firstType is a (or any) simple cast to integer. The default constructo for mytype is simply (integer, integer). What is the compiler doing here that it sees more than 2 expressions? Is the access to an array counting as one expression and then a cast to integer using firstType.cast as a second? I'm confused here and the workarounds are terrible for my situation.