cogent icon indicating copy to clipboard operation
cogent copied to clipboard

Variable of unboxed abstract type is treated as linear.

Open gteege opened this issue 5 years ago • 3 comments

type A
type B a

f : #(B A)  -> ()
f b = ()

causes the error message:

Parsing...
Resolving dependencies...
Typechecking...
Desugaring and typing...
Internal TC failed: Didn't use linear variable
Compilation failed!

If A is not abstract (replaced by U32) it works.

gteege avatar Nov 06 '19 16:11 gteege

~~Need to check if the Isabelle side agrees with the compiler.~~

zilinc avatar Nov 07 '19 05:11 zilinc

91101fc doesn't match the Isabelle spec. In the spec when it checks the kind of TCon tn ts s, it looks at both ts and the sigil s, whereas in the surface TC it only looks at the sigil. Core TC (before 91101fc) was actually correct w.r.t the spec.

zilinc avatar Nov 08 '19 02:11 zilinc

#T can either mean a stack object which contains pointers to the heap, or a purely stack allocated object. From the type we can't tell them apart. But their linearity properties are quite different: the former is linear, and the latter is non-linear. According to the Isabelle semantics, #T seems to mean the latter, but #(T A) means the former, which means that to express the former case, you are forced to parameterise the abstract type with something, but you can instantiate the type var with any linear type.

zilinc avatar Nov 08 '19 02:11 zilinc