Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Allow [t*] -> [t*] if blocks with no else (#135)
Browse files Browse the repository at this point in the history
* Allow `[t*] -> [t*]` if blocks with no else

As long as the start and end types are the same, then we don't need to require
an `else` block because a no-op will trivially implements that type signature.

* Version 0.39.2

(no api change)
  • Loading branch information
fitzgen authored and yurydelendik committed Sep 26, 2019
1 parent ac0ebbd commit 70000a6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmparser"
version = "0.39.1"
version = "0.39.2"
authors = ["Yury Delendik <ydelendik@mozilla.com>"]
license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/yurydelendik/wasmparser.rs"
Expand Down
4 changes: 2 additions & 2 deletions src/operators_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,9 @@ impl OperatorValidator {
}
if {
let last_block = &self.func_state.last_block();
last_block.is_else_allowed && !last_block.return_types.is_empty()
last_block.is_else_allowed && last_block.start_types != last_block.return_types
} {
return Err("else is expected: if block has type");
return Err("else is expected: if block has a type that can't be implemented with a no-op");
}
self.func_state.pop_block()
}
Expand Down
14 changes: 13 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ mod simple_tests {
}
assert_eq!(1, tests_count);
}

}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -372,6 +371,9 @@ mod wast_tests {
if config.operator_config.enable_simd {
features.enable_simd();
}
if config.operator_config.enable_multi_value {
features.enable_multi_value();
}
if config.operator_config.enable_reference_types {
features.enable_reference_types();
}
Expand Down Expand Up @@ -477,6 +479,16 @@ mod wast_tests {
},
);

run_proposal_tests(
"multi-value",
{
let mut config: ValidatingParserConfig = default_config();
config.operator_config.enable_multi_value = true;
config
},
|_name, _line| false,
);

run_proposal_tests(
"reference-types",
{
Expand Down

0 comments on commit 70000a6

Please sign in to comment.