Skip to content

Should check for existence of binding before creating a new one #19

Closed

Description

@jasonwilliams

Take this javascript..

let a = "foo";
a = "bar";

The error message we get is

thread 'main' panicked at 'Binding already exists!', src/lib/environment/global_environment_record.rs:108:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

This is because rather than re-using a the interpreter is attempting to create a new binding called a which already exists so causes an error.

https://github.com/jasonwilliams/boa/blob/master/src/lib/exec.rs#L333-L337 needs to be more clever. there needs to be a check here to see if the binding already exists, if it does use that binding and set it to a new value.

What does the spec say?

https://tc39.github.io/ecma262/#sec-assignment-operators-runtime-semantics-evaluation
https://tc39.github.io/ecma262/#sec-putvalue

Activity

  1. added
    Good First Issue
    Help Wanted
    on May 28, 2019
  2. perfectmak commented on Jun 20, 2019

    @perfectmak

    @jasonwilliams is this still available, I would like to work on it to better understand how boa works

  3. jasonwilliams commented on Jun 21, 2019

    @jasonwilliams
    MemberAuthor

    Sure go for it @perfectmak

  4. added this to the v0.4.0 milestone on Sep 8, 2019
  5. added a commit that references this issue on Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueHelp Wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions