Skip to content

fix: invalid dotted identifier notation error for sort #8260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Lean/Elab/App.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1503,15 +1503,19 @@ where
let resultTypeFn := resultType.cleanupAnnotations.getAppFn
try
tryPostponeIfMVar resultTypeFn
let .const declName .. := resultTypeFn.cleanupAnnotations
| throwError "invalid dotted identifier notation, expected type is not of the form (... → C ...) where C is a constant{indentExpr expectedType}"
let idNew := declName ++ id.getId.eraseMacroScopes
if (← getEnv).contains idNew then
mkConst idNew
else if let some (fvar, []) ← resolveLocalName idNew then
return fvar
else
throwUnknownIdentifier m!"invalid dotted identifier notation, unknown identifier `{idNew}` from expected type{indentExpr expectedType}"
match resultTypeFn.cleanupAnnotations with
| .const declName .. =>
let idNew := declName ++ id.getId.eraseMacroScopes
if (← getEnv).contains idNew then
mkConst idNew
else if let some (fvar, []) ← resolveLocalName idNew then
return fvar
else
throwUnknownIdentifier m!"invalid dotted identifier notation, unknown identifier `{idNew}` from expected type{indentExpr expectedType}"
| .sort .. =>
throwError "Invalid dotted identifier notation: not supported on type{indentExpr resultTypeFn}"
| _ =>
throwError "invalid dotted identifier notation, expected type is not of the form (... → C ...) where C is a constant{indentExpr expectedType}"
catch
| ex@(.error ..) =>
match (← unfoldDefinition? resultType) with
Expand Down
18 changes: 18 additions & 0 deletions tests/lean/run/invalid_dotted_identifier_prop.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/--
error: Invalid dotted identifier notation: not supported on type
Prop
-/
#guard_msgs in
def foo (n : Nat) : Nat :=
match n < 42 with
| .true => n
| .false => 47

/--
error: Invalid dotted identifier notation: not supported on type
Sort ?u.43
-/
#guard_msgs in
def foo2 (n : Nat) : Nat :=
match PUnit with
| .unit => n
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also test uses outside of patterns:

def Prop.true := True
#check (.true : Prop)

Loading