You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An internal compiler error is being produced when an union of generic record types is a type of a function argument whose function is inside a record definition. This can be illustrated with the following example code.
local record A<T>
a: T
end
local record B<T>
b: T
end
local record C<T>
f: function<T>(A<T> | B<T>)
end
When trying to run or check this code the following error message gets produced.
lua: C:\Lua\src\tl-0.24.1\/tl.lua:7304: Internal Compiler Error: error creating fresh type vari
ables
stack traceback:
[C]: in function 'assert'
C:\Lua\src\tl-0.24.1\/tl.lua:7304: in function <C:\Lua\src\tl-0.24.1\/tl.lua:7296>
(...tail calls...)
C:\Lua\src\tl-0.24.1\/tl.lua:4681: in upvalue 'recurse_type'
C:\Lua\src\tl-0.24.1\/tl.lua:4634: in upvalue 'recurse_type'
C:\Lua\src\tl-0.24.1\/tl.lua:4675: in upvalue 'recurse_type'
C:\Lua\src\tl-0.24.1\/tl.lua:4914: in local 'fn'
C:\Lua\src\tl-0.24.1\/tl.lua:4954: in upvalue 'recurse'
C:\Lua\src\tl-0.24.1\/tl.lua:4812: in local 'fn'
C:\Lua\src\tl-0.24.1\/tl.lua:4954: in upvalue 'recurse'
C:\Lua\src\tl-0.24.1\/tl.lua:4747: in local 'fn'
C:\Lua\src\tl-0.24.1\/tl.lua:4954: in function <C:\Lua\src\tl-0.24.1\/tl.lua:4929>
(...tail calls...)
C:\Lua\src\tl-0.24.1\/tl.lua:13311: in function 'tl.check'
C:\Lua\src\tl-0.24.1\/tl.lua:13447: in function 'tl.check_string'
(...tail calls...)
C:\Lua\src\tl-0.24.1\tl:239: in upvalue 'process_module'
C:\Lua\src\tl-0.24.1\tl:739: in field '?'
C:\Lua\src\tl-0.24.1\tl:977: in main chunk
[C]: in ?
When I slightly modify this example so that the function isn't inside a record and instead a standalone function then after running or checking the modified example code a proper error message gets produced. Below the modified example.
local record A<T>
a: T
end
local record B<T>
b: T
end
local function f<T>(a: A<T> | B<T>)
print(a)
end
f(nil)
And the associated error message.
1 error:
union.tl:9:24: cannot discriminate a union between multiple table types: A<T> | B<T>
----------------------------------------
1 error
Note. The f(nil) line in the modified example code is to suppress a warning.
Originally, I encountered this error with trying to modify functional.d.tl. See https://github.com/wqferr/functional/blob/master/functional.d.tl. I tried to prune the Iterator<T> record by merging duplicate function definitions into one with function argument types such as {T} | IIterator<T>. I later realized that it isn't possible because teal cannot discriminate union of multiple table types at runtime. But by loading the modified functional.d.tl file, I encountered this strange internal compiler error. I managed to reduce it to this simple example code.
The text was updated successfully, but these errors were encountered:
An internal compiler error is being produced when an union of generic record types is a type of a function argument whose function is inside a record definition. This can be illustrated with the following example code.
When trying to run or check this code the following error message gets produced.
When I slightly modify this example so that the function isn't inside a record and instead a standalone function then after running or checking the modified example code a proper error message gets produced. Below the modified example.
And the associated error message.
Note. The
f(nil)
line in the modified example code is to suppress a warning.Originally, I encountered this error with trying to modify
functional.d.tl
. See https://github.com/wqferr/functional/blob/master/functional.d.tl. I tried to prune theIterator<T>
record by merging duplicate function definitions into one with function argument types such as{T} | IIterator<T>
. I later realized that it isn't possible because teal cannot discriminate union of multiple table types at runtime. But by loading the modifiedfunctional.d.tl
file, I encountered this strange internal compiler error. I managed to reduce it to this simple example code.The text was updated successfully, but these errors were encountered: