Understandably esoteric and might be out of scope, reporting anyway.
Something like
local test = array( 10, null ).apply( @( val, i ) val = i )
Results in the type system still assuming the array elements are null rather than integer or integer|null
Noticed when doing this trick to get floats from a KVString
local origin = split( config.leaderboard_cam, " " ).apply( @( str ) str.tofloat() )
// expected 'float', got 'string' warning
leaderboard_cam_pos = Vector( origin[0], origin[1], origin[2] )
I imagine trying to support every modify-in-place mutation for arrays/tables would be messy and annoying, and possibly undermines the point of type checking in the first place if gone too far. For specifically in-line array declaration + apply trickery like this though, maybe the apply funcs return value could be used for type inference instead.
If out of scope, is there a way to explicitly override variable types with a Tag?
Understandably esoteric and might be out of scope, reporting anyway.
Something like
Results in the type system still assuming the array elements are
nullrather thanintegerorinteger|nullNoticed when doing this trick to get floats from a KVString
I imagine trying to support every modify-in-place mutation for arrays/tables would be messy and annoying, and possibly undermines the point of type checking in the first place if gone too far. For specifically in-line array declaration + apply trickery like this though, maybe the apply funcs return value could be used for type inference instead.
If out of scope, is there a way to explicitly override variable types with a Tag?