Skip to content

Commit

Permalink
fix: default values for structure fields can be noncomputable (#5531)
Browse files Browse the repository at this point in the history
Closes #2710
  • Loading branch information
kmill authored Sep 30, 2024
1 parent a4dfa83 commit cf14178
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Lean/Elab/Structure.lean
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ private def addDefaults (lctx : LocalContext) (defaultAuxDecls : Array (Name ×
throwError "invalid default value for field, it contains metavariables{indentExpr value}"
/- The identity function is used as "marker". -/
let value ← mkId value
discard <| mkAuxDefinition declName type value (zetaDelta := true)
-- No need to compile the definition, since it is only used during elaboration.
discard <| mkAuxDefinition declName type value (zetaDelta := true) (compile := false)
setReducibleAttribute declName

/--
Expand Down
8 changes: 8 additions & 0 deletions tests/lean/run/2710.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/-!
# Structure field default values can be noncomputable
-/

noncomputable def ohno := 1

structure OhNo where
x := ohno

0 comments on commit cf14178

Please sign in to comment.