You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we try to define an identifier inside a function with the name arguments, this fails with a panic saying that "Identifier arguments has already been declared". You can test this with the following Test262 tests:
RUST_BACKTRACE=1 cargo run --release --bin boa_tester -- run -v -s {file}
Where {file} is one of the paths in the list above.
You will get a backtrace like this one:
0: rust_begin_unwind
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
1: std::panicking::begin_panic_fmt
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:437:5
2: <boa::environment::function_environment_record::FunctionEnvironmentRecord as boa::environment::environment_record_trait::EnvironmentRecordTrait>::create_mutable_binding
3: boa::environment::lexical_environment::LexicalEnvironment::create_mutable_binding
4: <boa::syntax::ast::node::Node as boa::exec::Executable>::run
5: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
6: boa::object::gcobject::GcObject::call
7: <boa::syntax::ast::node::call::Call as boa::exec::Executable>::run
8: <boa::syntax::ast::node::block::Block as boa::exec::Executable>::run
9: <boa::syntax::ast::node::Node as boa::exec::Executable>::run
10: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
11: boa::object::gcobject::GcObject::call
12: <boa::syntax::ast::node::call::Call as boa::exec::Executable>::run
13: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
14: boa::context::Context::eval
15: boa_tester::exec::<impl boa_tester::Test>::run_once
16: boa_tester::exec::<impl boa_tester::Test>::run
17: boa_tester::main
The panic would be this one:
thread 'main' panicked at 'Identifier arguments has already been declared', boa/src/environment/function_environment_record.rs:108:13
This happens because we assert here that a binding that doesn't allow re-declaration (such as a let binding) won't be able to get re-declared. The issue is that in every function, an arguments variable gets declared here and here. Even if that variable can be re-declared, the let binding cannot, and this makes it panic.
Our environment representation is not quite spec compliant, but the thing is that if a variable can be re-declared, then it should be in the new declaration when we check if that variable can be re-declared, not when declaring the variable gets declared for the first time, so this information should be persisted.
The text was updated successfully, but these errors were encountered:
When we try to define an identifier inside a function with the name
arguments
, this fails with a panic saying that "Identifier arguments has already been declared". You can test this with the following Test262 tests:test/language/eval-code/direct/func-decl-fn-body-cntns-arguments-lex-bind-declare-arguments.js
test/language/eval-code/direct/func-decl-fn-body-cntns-arguments-lex-bind-declare-arguments-and-assign.js
test/language/eval-code/direct/meth-fn-body-cntns-arguments-lex-bind-declare-arguments.js
test/language/eval-code/direct/meth-fn-body-cntns-arguments-lex-bind-declare-arguments-and-assign.js
test/language/eval-code/direct/func-expr-fn-body-cntns-arguments-lex-bind-declare-arguments.js
test/language/eval-code/direct/func-expr-fn-body-cntns-arguments-lex-bind-declare-arguments-and-assign.js
test/language/statements/function/arguments-with-arguments-lex.js
test/language/expressions/function/arguments-with-arguments-lex.js
To run any of them, you just need to run:
Where
{file}
is one of the paths in the list above.You will get a backtrace like this one:
The panic would be this one:
This happens because we assert here that a binding that doesn't allow re-declaration (such as a
let
binding) won't be able to get re-declared. The issue is that in every function, anarguments
variable gets declared here and here. Even if that variable can be re-declared, thelet
binding cannot, and this makes it panic.Our environment representation is not quite spec compliant, but the thing is that if a variable can be re-declared, then it should be in the new declaration when we check if that variable can be re-declared, not when declaring the variable gets declared for the first time, so this information should be persisted.
The text was updated successfully, but these errors were encountered: