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
local record Struct<T>
a: T
b: T
c: self
end
local a: Struct<integer> = {
a = 1,
b = 2,
c = 3,
}
print(a.a, a.b, a.c)
If in the example code the self type gets replaced with Struct<T> then the following error message gets produced.
1 error:
self.tl:10:6: in record field: c: got integer, expected Struct<integer>
----------------------------------------
1 error
The same happens if the self type is inside a function. Here with a similar example.
local record Struct<T>
a: T
b: T
c: function<T>(self)
end
local a: Struct<integer> = {
a = 1,
b = 2,
c = function(a: integer) end,
}
print(a.a, a.b, a.c)
This example also erroneously passes with some warnings. If the self type gets replaced with Struct<T> then the following error message gets produced.
========================================
2 warnings:
self.tl:4:14: type argument shadows previous declaration of 'T'
self.tl:10:15: unused argument a: integer
----------------------------------------
2 warnings
========================================
1 error:
self.tl:10:18: in record field: c: argument 1: got integer, expected Struct<T>
----------------------------------------
1 error
The text was updated successfully, but these errors were encountered:
The following example code erroneously passes.
If in the example code the self type gets replaced with
Struct<T>
then the following error message gets produced.The same happens if the self type is inside a function. Here with a similar example.
This example also erroneously passes with some warnings. If the self type gets replaced with
Struct<T>
then the following error message gets produced.The text was updated successfully, but these errors were encountered: