test: default value set at copied structure

This commit is contained in:
Leonardo de Moura 2021-08-10 19:00:34 -07:00
parent 3b1285bee8
commit ae03f15c92
2 changed files with 15 additions and 1 deletions

View file

@ -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!

View file

@ -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