Skip to content

Commit

Permalink
Revert br_table in reference types proposal (#1484)
Browse files Browse the repository at this point in the history
The reference types proposal originally modified the `br_table` behavior
to only check arity, not the specific types. This was to remove a
subtyping check, but now that subtyping has been removed, we can revert
back to the original (MVP) br_table behavior.
  • Loading branch information
binji authored Jul 15, 2020
1 parent 3e8b0bb commit 3041d94
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
20 changes: 5 additions & 15 deletions src/type-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,11 @@ Result TypeChecker::OnBrTableTarget(Index depth) {
if (br_table_sig_ == nullptr) {
br_table_sig_ = &label_sig;
} else {
if (features_.reference_types_enabled()) {
if (br_table_sig_->size() != label_sig.size()) {
result |= Result::Error;
PrintError("br_table labels have inconsistent arity: expected %" PRIzd
" got %" PRIzd,
br_table_sig_->size(), label_sig.size());
}
} else {
if (*br_table_sig_ != label_sig) {
result |= Result::Error;
PrintError(
"br_table labels have inconsistent types: expected %s, got %s",
TypesToString(*br_table_sig_).c_str(),
TypesToString(label_sig).c_str());
}
if (*br_table_sig_ != label_sig) {
result |= Result::Error;
PrintError("br_table labels have inconsistent types: expected %s, got %s",
TypesToString(*br_table_sig_).c_str(),
TypesToString(label_sig).c_str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/spec/reference-types/br_table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ out/test/spec/reference-types/br_table.wast:1461: assert_invalid passed:
error: type mismatch in br_table, expected [i32] but got [i64]
0000023: error: OnBrTableExpr callback failed
out/test/spec/reference-types/br_table.wast:1469: assert_invalid passed:
error: br_table labels have inconsistent arity: expected 1 got 0
error: br_table labels have inconsistent types: expected [f32], got []
0000026: error: OnBrTableExpr callback failed
out/test/spec/reference-types/br_table.wast:1481: assert_invalid passed:
error: type mismatch in br_table, expected [i32] but got []
Expand Down
2 changes: 1 addition & 1 deletion test/spec/reference-types/unreached-invalid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ out/test/spec/reference-types/unreached-invalid.wast:521: assert_invalid passed:
error: type mismatch in br_table, expected [i32] but got [f32]
0000025: error: OnBrTableExpr callback failed
out/test/spec/reference-types/unreached-invalid.wast:527: assert_invalid passed:
error: br_table labels have inconsistent arity: expected 1 got 0
error: br_table labels have inconsistent types: expected [f32], got []
0000023: error: OnBrTableExpr callback failed
out/test/spec/reference-types/unreached-invalid.wast:540: assert_invalid passed:
error: type mismatch in block, expected [] but got [i32]
Expand Down

0 comments on commit 3041d94

Please sign in to comment.