Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion nova_vm/src/ecmascript/scripts_and_modules/source_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<'a> SourceCode<'a> {
panicked,
..
} = sloppy_result;
if panicked {
if panicked || !sloppy_errors.is_empty() {
return Err(sloppy_errors);
}
let SemanticBuilderReturn {
Expand Down Expand Up @@ -433,6 +433,40 @@ mod test {
assert!(!errors.is_empty());
}

#[test]
fn strict_script_with_top_level_await() {
let (mut gc, mut scope) = unsafe { GcScope::create_root() };
let mut gc = GcScope::new(&mut gc, &mut scope);
let mut agent = Agent::new(AgentOptions::default(), &DefaultHostHooks);
initialize_default_realm(&mut agent, gc.reborrow());

for source_type in [
SourceCodeType::Script { strict: true },
SourceCodeType::Eval {
direct: false,
strict: true,
},
] {
for source in ["await 10;", "for await (let x of []) {}"] {
let source_text = String::from_static_str(&mut agent, source, gc.nogc());
// SAFETY: tests.
let errors = unsafe {
SourceCode::parse_source(
&mut agent,
source_text,
source_type,
#[cfg(feature = "typescript")]
false,
gc.nogc(),
)
}
.unwrap_err();

assert!(!errors.is_empty());
}
}
}

#[test]
fn parse_and_realloc_source_codes_with_program() {
let (mut gc, mut scope) = unsafe { GcScope::create_root() };
Expand Down
2 changes: 0 additions & 2 deletions tests/expectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -7439,7 +7439,6 @@
"staging/sm/Array/unscopables.js": "FAIL",
"staging/sm/Array/values.js": "FAIL",
"staging/sm/ArrayBuffer/slice-species.js": "FAIL",
"staging/sm/AsyncGenerators/for-await-of-error.js": "CRASH",
"staging/sm/BigInt/Number-conversion-rounding.js": "FAIL",
"staging/sm/BigInt/large-bit-length.js": "TIMEOUT",
"staging/sm/Date/dst-offset-caching-1-of-8.js": "TIMEOUT",
Expand Down Expand Up @@ -7678,7 +7677,6 @@
"staging/sm/TypedArray/sort-non-function.js": "FAIL",
"staging/sm/TypedArray/test-integrity-level-detached.js": "FAIL",
"staging/sm/TypedArray/toString.js": "FAIL",
"staging/sm/async-functions/await-error.js": "CRASH",
"staging/sm/async-functions/await-in-arrow-parameters.js": "FAIL",
"staging/sm/async-functions/await-in-parameters-of-async-func.js": "FAIL",
"staging/sm/async-functions/toString.js": "FAIL",
Expand Down
4 changes: 2 additions & 2 deletions tests/metrics.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"results": {
"crash": 162,
"crash": 160,
"fail": 7572,
"pass": 40692,
"pass": 40694,
"skip": 5127,
"timeout": 22,
"unresolved": 41
Expand Down