Skip to content
Merged
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
8 changes: 4 additions & 4 deletions src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use ahash::AHashSet;
use anyhow::{Context, anyhow};
use anyhow::{Context, anyhow, bail};
use counter::Counter;
#[cfg(test)]
use num::BigInt;
Expand Down Expand Up @@ -1046,7 +1046,7 @@ fn compile_debug_lit(chunk: &mut Chunk, ch: &DebugKind, line: usize) -> anyhow::
}
DebugKind::Char('~') => {
// Be a compiler error
anyhow::bail!("@@~ token detected. aborting compilation.")
bail!("@@~ token detected. aborting compilation.")
}
DebugKind::Char(_) => (),
}
Expand Down Expand Up @@ -3032,7 +3032,7 @@ impl OptionalChain {
chunk.op_plus_arg(Insn::Unwind, 1, line);
evaluate_property_access_with_identifier_key(chunk, id, strict, line).map(CompilerStatusFlags::from)
}
OptionalChain::Template(_, _) => todo!(),
OptionalChain::Template(_, _) => bail!("Template literals are not allowed in optional chains"),
OptionalChain::PrivateId(id, _) => {
// OptionalChain : ?. PrivateIdentifier
// 1. Let fieldNameString be the StringValue of PrivateIdentifier.
Expand Down Expand Up @@ -3709,7 +3709,7 @@ impl RelationalExpression {
RelationalExpression::GreaterEqual(_, _) => Insn::GreaterEqual,
RelationalExpression::InstanceOf(_, _) => Insn::InstanceOf,
RelationalExpression::In(_, _) => Insn::In,
_ => anyhow::bail!("RelationalExpression has no binary instruction"),
_ => bail!("RelationalExpression has no binary instruction"),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12793,7 +12793,7 @@ mod optional_chain {
=> Ok((svec(&["00001: ?.a", "UNWIND 1", "STRING 0 (a)", "STRICT_REF"]), false, true));
"oc: id; success"
)]
#[test_case("?.``", true, &[] => panics "not yet implemented"; "oc: template")]
#[test_case("?.``", true, &[] => serr("Template literals are not allowed in optional chains"); "oc: template")]
#[test_case(
"?.#a", true, &[]
=> Ok((svec(&["00001: ?.#a", "UNWIND 1", "PRIVATE_REF 0 (#a)"]), false, true));
Expand Down
Loading