feat: throw error at field names starting with '_'

This commit is contained in:
Leonardo de Moura 2020-07-21 10:09:16 -07:00
parent 9724f02b0e
commit 19fc369875
2 changed files with 8 additions and 0 deletions

View file

@ -129,6 +129,8 @@ fieldBinders.foldlM
idents.foldlM
(fun (views : Array StructFieldView) ident => do
let name := ident.getId;
when (isInternalSubobjectFieldName name) $
throwError ident ("invalid field name '" ++ name ++ "', identifiers starting with '_' are reserved to the system");
let declName := structDeclName ++ name;
declName ← applyVisibility ident modifiers.visibility declName;
pure $ views.push {

View file

@ -17,3 +17,9 @@ structure S extends A Nat, A Bool := -- error field toA already declared
structure S extends A Nat, B Bool := -- error field `x` from `B` has already been declared
(x : Nat)
structure S := -- error '_' is not allowed
(_x : Nat)
structure S := -- error '_' is not allowed
(x _y : Nat)