parent
781a28b8f4
commit
9a152d2051
2 changed files with 23 additions and 1 deletions
|
|
@ -851,7 +851,22 @@ private def elabStructInstAux (stx : Syntax) (expectedType? : Option Expr) (sour
|
|||
let struct ← liftMacroM <| mkStructView stx structName source
|
||||
let struct ← expandStruct struct
|
||||
trace[Elab.struct] "{struct}"
|
||||
let (r, struct) ← elabStruct struct expectedType?
|
||||
/- We try to synthesize pending problems with `withSynthesize` combinator before trying to use default values.
|
||||
This is important in examples such as
|
||||
```
|
||||
structure MyStruct where
|
||||
{α : Type u}
|
||||
{β : Type v}
|
||||
a : α
|
||||
b : β
|
||||
|
||||
#check { a := 10, b := true : MyStruct }
|
||||
```
|
||||
were the `α` will remain "unknown" until the default instance for `OfNat` is used to ensure that `10` is a `Nat`.
|
||||
|
||||
TODO: investigate whether this design decision may have unintended side effects or produce confusing behavior.
|
||||
-/
|
||||
let (r, struct) ← withSynthesize (mayPostpone := true) <| elabStruct struct expectedType?
|
||||
trace[Elab.struct] "before propagate {r}"
|
||||
DefaultFields.propagate struct
|
||||
return r
|
||||
|
|
|
|||
7
tests/lean/run/783.lean
Normal file
7
tests/lean/run/783.lean
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
structure MyStruct where
|
||||
{α : Type u}
|
||||
{β : Type v}
|
||||
a : α
|
||||
b : β
|
||||
|
||||
#check { a := 10, b := true : MyStruct }
|
||||
Loading…
Add table
Reference in a new issue