diff --git a/lib/parse.ml b/lib/parse.ml index 30b0263..7d3153d 100644 --- a/lib/parse.ml +++ b/lib/parse.ml @@ -64,6 +64,12 @@ let builtin_types = let rec texpr (f : Form.t) : Ast.texpr = let mk t = { Ast.t; tloc = f.loc } in match f.v with + (* Unit is spelled [()], ML's spelling. It is the honest name, and it cannot + collide with anything: an empty call is not a valid expression, so [()] has + no reading in value position to be confused with. Internally it stays + [Tname "Unit"] -- the resolver, the shim and the emitter all speak that + name, and diagnostics still print it. *) + | List [] -> mk (Ast.Tname "Unit") | Sym s -> mk (Ast.Tname s) | Vec [ elem ] -> mk (Ast.Tslice (texpr elem)) | Vec [ n; elem ] -> mk (Ast.Tarray (len n, texpr elem)) @@ -865,6 +871,7 @@ and qualified_type types s = and is_type_form types (f : Form.t) = match f.v with + | List [] -> true (* () is unit, never a body form *) | Sym s -> Names.mem s types || Names.mem ("enum " ^ s) types || Names.mem ("prelude " ^ s) types || qualified_type types s