diff --git a/src/Lean/Elab/Structure.lean b/src/Lean/Elab/Structure.lean index f030e2892d..8439a49b79 100644 --- a/src/Lean/Elab/Structure.lean +++ b/src/Lean/Elab/Structure.lean @@ -380,7 +380,7 @@ where let existingFieldType ← inferType existingFieldInfo.fvar unless (← isDefEq fieldType existingFieldType) do throwError "parent field type mismatch, field '{fieldName}' from parent '{parentStructName}' {← mkHasTypeButIsExpectedMsg fieldType existingFieldType}" - -- TODO: if new field has a default value, it should probably override the default at `infos` (if it has one) + /- Remark: if structure has a default value for this field, it will be set at the `processOveriddenDefaultValues` below. -/ copy (i+1) (fieldMap.insert fieldName existingFieldInfo.fvar) infos | none => let some fieldInfo ← getFieldInfo? (← getEnv) parentStructName fieldName | unreachable! diff --git a/tests/lean/run/diamond4.lean b/tests/lean/run/diamond4.lean new file mode 100644 index 0000000000..d8b738d960 --- /dev/null +++ b/tests/lean/run/diamond4.lean @@ -0,0 +1,14 @@ +structure A where + a : Nat + +structure B where + a : Nat := 1 + b : Nat + +structure C extends A, B + +def f (b : Nat) : C := + { b } + +theorem ex (b : Nat) : (f b).a = 1 := + rfl