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
Global interfaces and type aliases may be used in declarations before they are actually declared, as long as there is no interving code that needs the declarations for typechecking (Typed Lua is still a single-pass compiler). This should also allow the declaration of mutually recursive interfaces and type aliases. An example:
-- The following two mutually recursive types are the same structurallyinterfaceTree1label: integerleft: Tree2?
right: Tree2?
endinterfaceTree2label: integerleft: Tree1?
right: Tree1?
end-- the following type has a forward referenceinterfaceOBJparent: OBJ?
atr: ELEMendinterfaceELEMx: integerendlocalfunctionf(o:OBJ)
localt1: Tree1= { label=2 }
localt2: Tree2= { label=3 }
t1=t2-- ok because Tree2 <: Tree2t2=t1-- ok because Tree1 <: Tree2localparent=o.parentifparentthenf({atr={x=2}})
endend
The text was updated successfully, but these errors were encountered:
Global interfaces and type aliases may be used in declarations before they are actually declared, as long as there is no interving code that needs the declarations for typechecking (Typed Lua is still a single-pass compiler). This should also allow the declaration of mutually recursive interfaces and type aliases. An example:
The text was updated successfully, but these errors were encountered: