Open Andre-LA opened 1 year ago
If you define a working generic type inside a record (being used as a namespace), it throws an assertion error.
## local make_something = generalize(function(T) local MyGeneric = @record{ value: #[T]# } function MyGeneric:get_value() return self.value end ## return MyGeneric ## end) local Something = #[make_something]# local MyNamespace = @record{} local MyNamespace.Something = @Something --- -- local GenericNum = @Something(integer) -- works local GenericNum = @MyNamespace.Something(integer) -- assertion failed local num: GenericNum = { 5 } print(num:get_value())
The same behavior when using the generic directly
Just alias to the generic and use it directly:
local SomethingAlias = @MyNamespace.Something local GenericNum = @SomethingAlias(integer) -- works
It's something I've been aware, it's a limitation for now, will take a look at this eventually.
Bug description
If you define a working generic type inside a record (being used as a namespace), it throws an assertion error.
Code example
Expected behavior
The same behavior when using the generic directly
Workaround
Just alias to the generic and use it directly:
Environment