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 std =require"std"
struct S {
k: int
}
std.Vector(S) -- compile fails without this lineterramain()
var a = [std.Vector(S)].salloc():init()
a:insert().k =1
a:insert().k =2
a:insert().k =3for i =0ULL, a:size() do
std.printf("x[%llu].k: %d\n", i, a(i).k)
end
std.printf("#%llu\n", f(a))
endterraf(v: &std.Vector(S)): uint64
return v:size()
end
main()
Without the commented line, compilation fails:
/terra/src/terralib.lua:1105: attempting to use type S before it is defined.
stack traceback:
[C]: in function 'error'
/terra/src/terralib.lua:381: in function 'erroratlocation'
/terra/src/terralib.lua:1524: in function 'getvalue'
/terra/src/terralib.lua:1373: in function 'getentries'
/terra/src/terralib.lua:1563: in function 'getvalue'
/terra/src/terralib.lua:1373: in function 'getlayout'
/terra/src/terralib.lua:1642: in function 'userfn'
[string "/std.t"]:119: Errors reported during finalizing type
/terra/src/terralib.lua:2986: in function 'docheck'
/terra/src/terralib.lua:3120: in function 'checkexp'
...
[string "/std.t"]:110: in function 'fn'
/terra/src/terralib.lua:1250: in function 'Vector'
t5.t:20: in function 'userfn'
t5.t:20: Errors reported during evaluating Lua code from Terra
terra f(v: &std.Vector(S)): uint64
^
/terra/src/terralib.lua:1843: in function 'evalluaexpression'
/terra/src/terralib.lua:1850: in function 'evaltype'
/terra/src/terralib.lua:1870: in function 'evaluateparameterlist'
/terra/src/terralib.lua:1068: in function 'evalformalparameters'
/terra/src/terralib.lua:1143: in function 'defineobjects'
t5.t:3: in main chunk
The text was updated successfully, but these errors were encountered:
I agree that it doesn't seem like this ought to fail. The struct S is clearly defined, and if you go take a look at the std.t source you'll see the Vector type is too.
Unfortunately I don't have time to dig in further right now, but it probably has something to do with Terra's ordering of compilation. If you want to help out, I'd trace through the compiler to see what difference that line makes; presumably there is some path (e.g., completing a type T when used as &T) that's missing that ought to be there.
In this code:
Without the commented line, compilation fails:
The text was updated successfully, but these errors were encountered: