diff --git a/crates/elp/src/resources/test/eqwalizer_tests/check/guards.pretty b/crates/elp/src/resources/test/eqwalizer_tests/check/guards.pretty index aec450a5c..4162e45dd 100644 --- a/crates/elp/src/resources/test/eqwalizer_tests/check/guards.pretty +++ b/crates/elp/src/resources/test/eqwalizer_tests/check/guards.pretty @@ -24,14 +24,6 @@ error: reference_to_invalid_type See https://fb.me/eqwalizer_errors#reference_to_invalid_type -error: unbound_record - ┌─ check/src/guards.erl:57:19 - │ -57 │ test06_neg() when #invalid{} =/= 2 -> ok. - │ ^^^^^^^^^^ Unbound rec: invalid - -See https://fb.me/eqwalizer_errors#unbound_record - error: incompatible_types ┌─ check/src/guards.erl:89:25 │ @@ -42,4 +34,4 @@ Context expected type: number() See https://fb.me/eqwalizer_errors#incompatible_types -5 ERRORS +4 ERRORS diff --git a/crates/elp/src/resources/test/eqwalizer_tests/check/records.pretty b/crates/elp/src/resources/test/eqwalizer_tests/check/records.pretty index 4b861b87a..66b03dfcb 100644 --- a/crates/elp/src/resources/test/eqwalizer_tests/check/records.pretty +++ b/crates/elp/src/resources/test/eqwalizer_tests/check/records.pretty @@ -483,29 +483,25 @@ error: reference_to_invalid_type See https://fb.me/eqwalizer_errors#reference_to_invalid_type -error: unbound_record +error: incompatible_types ┌─ check/src/records.erl:425:5 │ 425 │ X#invalid.field. - │ ^^^^^^^^^^^^^^^ Unbound rec: invalid + │ ^ X. +Expression has type: term() +Context expected type: #invalid{} -See https://fb.me/eqwalizer_errors#unbound_record +See https://fb.me/eqwalizer_errors#incompatible_types -error: unbound_record +error: incompatible_types ┌─ check/src/records.erl:429:9 │ 429 │ _ = X#invalid.field, - │ ^^^^^^^^^^^^^^^ Unbound rec: invalid - -See https://fb.me/eqwalizer_errors#unbound_record + │ ^ X. +Expression has type: term() +Context expected type: #invalid{} -error: unbound_record - ┌─ check/src/records.erl:434:5 - │ -434 │ X#invalid{field = 2}. - │ ^^^^^^^^^^^^^^^^^^^^ Unbound rec: invalid - -See https://fb.me/eqwalizer_errors#unbound_record +See https://fb.me/eqwalizer_errors#incompatible_types error: reveal_type ┌─ check/src/records.erl:445:27 @@ -593,4 +589,4 @@ See https://fb.me/eqwalizer_errors#incompatible_types because term() is not compatible with atom() -46 ERRORS +45 ERRORS diff --git a/crates/elp/src/resources/test/eqwalizer_tests/check/type_aliases.pretty b/crates/elp/src/resources/test/eqwalizer_tests/check/type_aliases.pretty index 42ee47a0d..6e4731af4 100644 --- a/crates/elp/src/resources/test/eqwalizer_tests/check/type_aliases.pretty +++ b/crates/elp/src/resources/test/eqwalizer_tests/check/type_aliases.pretty @@ -180,14 +180,6 @@ error: reference_to_invalid_type See https://fb.me/eqwalizer_errors#reference_to_invalid_type -error: unbound_record - ┌─ check/src/type_aliases.erl:99:9 - │ -99 │ convert(#rec1{l = L1}, #rec2{l = L2}) -> - │ ^^^^^^^^^^^^^ Unbound rec: rec1 - -See https://fb.me/eqwalizer_errors#unbound_record - error: unknown_id ┌─ check/src/type_aliases.erl:104:21 │ @@ -206,4 +198,4 @@ error: reference_to_invalid_type See https://fb.me/eqwalizer_errors#reference_to_invalid_type -23 ERRORS +22 ERRORS diff --git a/crates/eqwalizer/src/ast/trans_valid.rs b/crates/eqwalizer/src/ast/trans_valid.rs index 29004bc7b..9cd1fb717 100644 --- a/crates/eqwalizer/src/ast/trans_valid.rs +++ b/crates/eqwalizer/src/ast/trans_valid.rs @@ -202,7 +202,15 @@ impl TransitiveChecker<'_> { name: t.name.clone(), references: invalids, }); - stub.records.remove(&t.name); + // we don't know at this point which fields are invalid, + // so replacing all the fields with dynamic type + stub.records.get_mut(&t.name).map(|rec_decl| { + rec_decl.fields.iter_mut().for_each(|field| { + if field.tp.is_some() { + field.tp = Some(Type::DynamicType) + } + }) + }); stub.invalid_forms .push(InvalidForm::InvalidRecDecl(InvalidRecDecl { location: t.location.clone(),