Skip to content
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

fix: make generalized field notation for abbreviation types handle optional parameters #3746

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/Lean/Elab/App.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ private partial def mkBaseProjections (baseStructName : Name) (structName : Name
private def typeMatchesBaseName (type : Expr) (baseName : Name) : MetaM Bool := do
if baseName == `Function then
return (← whnfR type).isForall
else if type.consumeMData.isAppOf baseName then
else if type.cleanupAnnotations.isAppOf baseName then
return true
else
return (← whnfR type).isAppOf baseName
Expand Down
31 changes: 31 additions & 0 deletions tests/lean/run/3745.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/-!
# Issue 3745

Field notation for abbreviations would fail if the argument for field notation was an optional parameter.
-/

structure A

abbrev B := A

def A.x (_ : A) := 1
def B.x (_ : B) := 2

def A.y (_ : A) := 1
def B.y (_ : B := {}) := 2

/-!
These were OK before the fix.
-/
/-- info: 1 -/
#guard_msgs in #eval (show A from {}).x
/-- info: 2 -/
#guard_msgs in #eval (show B from {}).x

/-!
The second of these failed before the fix.
-/
/-- info: 1 -/
#guard_msgs in #eval (show A from {}).y
/-- info: 2 -/
#guard_msgs in #eval (show B from {}).y
Loading