fix: ensure field names are atomic

This commit is contained in:
Leonardo de Moura 2021-08-09 16:02:33 -07:00
parent 52710688f7
commit e8403f89b0
3 changed files with 6 additions and 1 deletions

View file

@ -207,7 +207,9 @@ private def expandFields (structStx : Syntax) (structModifiers : Modifiers) (str
pure (some optBinderTacticDefault[0][1])
let idents := fieldBinder[2].getArgs
idents.foldlM (init := views) fun (views : Array StructFieldView) ident => withRef ident do
let name := ident.getId
let name := ident.getId.eraseMacroScopes
unless name.isAtomic do
throwErrorAt ident "invalid field name '{name.eraseMacroScopes}', field names must be atomic"
let declName := structDeclName ++ name
let declName ← applyVisibility fieldModifiers.visibility declName
addDocString' declName fieldModifiers.docString?

View file

@ -0,0 +1,2 @@
structure A where
a.b : Nat

View file

@ -0,0 +1 @@
nonAtomicFieldName.lean:2:2-2:5: error: invalid field name 'a.b', field names must be atomic