fix: ensure field names are atomic
This commit is contained in:
parent
52710688f7
commit
e8403f89b0
3 changed files with 6 additions and 1 deletions
|
|
@ -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?
|
||||
|
|
|
|||
2
tests/lean/nonAtomicFieldName.lean
Normal file
2
tests/lean/nonAtomicFieldName.lean
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
structure A where
|
||||
a.b : Nat
|
||||
1
tests/lean/nonAtomicFieldName.lean.expected.out
Normal file
1
tests/lean/nonAtomicFieldName.lean.expected.out
Normal file
|
|
@ -0,0 +1 @@
|
|||
nonAtomicFieldName.lean:2:2-2:5: error: invalid field name 'a.b', field names must be atomic
|
||||
Loading…
Add table
Reference in a new issue