Skip to content

Hoisting variables #376

Closed
Closed

Description

@hello2dj

now not founding Identifier will always be undefined, for function or var this is wrong.

moreinfo

example:

// v8
console.log(A); // [Function: A]
function A() {}
// boa
console.log(A); // undefined
function A() {}

Activity

  1. added
    A-Bug
    on May 7, 2020
  2. Razican commented on May 7, 2020

    @Razican
    Member

    This seems to be related to the fact that we execute nodes in order, instead of having a special category for this. These functions should be evaluated first, and then start evaluating the rest of statements.

  3. self-assigned this
    on May 14, 2020
  4. added this to the v0.9.0 milestone on May 14, 2020
  5. linked a pull request that will close this issueExecution and Node modularization #392on May 14, 2020
  6. jasonwilliams commented on May 18, 2020

    @jasonwilliams
    Member

    I don't think v0.9.0 is realistic for this, for hoisting to work would require a big refactor of how execution works, including having some pre-parsing step.

    We're no where near that point yet.

  7. Razican commented on May 18, 2020

    @Razican
    Member

    I don't think v0.9.0 is realistic for this, for hoisting to work would require a big refactor of how execution works, including having some pre-parsing step.

    We're no where near that point yet.

    Actually, this seems to be already working in #392. The Idea was to re-order function declarations to show before all the rest of the nodes in the node list. Not sure what else should be done.

  8. jasonwilliams commented on May 18, 2020

    @jasonwilliams
    Member

    oh ok interesting.
    Should we be doing something more closely related to https://v8.dev/blog/preparser#variable-allocation? is reordering sound?

  9. Razican commented on May 18, 2020

    @Razican
    Member

    Should we be doing something more closely related to https://v8.dev/blog/preparser#variable-allocation?

    Definitelly, but I think it's a reasonable workaround in the meantime.

    is reordering sound?

    It should be, it's slower, as we will be doing a sort, but it's always maintaining ordering, so it's sound as far as I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-Bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions