Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the canonical value of undefined in generated JavaScript code. #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 9, 2019

  1. Use the canonical value of undefined in generated JavaScript code.

    Using `undefined` in generated code is fragile as it is global mutable
    variable, not a constant. As a consequence a buggy equality test such
    as `if (foo = undefined) { ... }` or similar in generated code or any
    third-party code can inadvertently break the entire runtime. Such bugs
    can be difficult to localise.
    
    To make the runtime more robust this patch introduces a slight change
    to the JavaScript code generator such that the emitted code uses the
    canonical value of `undefined` rather than the variable name
    `undefined`. The canonical value can be obtain via the odd expression
    `(void 0)`. Since `void` is a keyword and `0` is a numeric literal it
    is not possible for user-code to override their semantics, hence the
    expression is resilient against mutations such as monkey-patching.
    dhil committed Aug 9, 2019
    Configuration menu
    Copy the full SHA
    2a1267b View commit details
    Browse the repository at this point in the history