Skip to content

Instantly share code, notes, and snippets.

@zenparsing
zenparsing / strict-error-detection.md
Last active December 30, 2015 00:59
Simplified algorithm for detection of strict-mode errors in ECMAScript 6.

A context object is associated with any AST node which may have "strictness". Each context has a strictness state: UNKOWN, STRICT, and NOT_STRICT. In order to account for arrow functions, parenthesized expressions are also assigned a context.

When a context C is pushed:

  • set C.parent to the current context object
  • set C.strictError to null
  • if C.parent.strict is STRICT
    • set C.strict to STRICT
  • else
  • set C.strict to UNKNOWN
@zenparsing
zenparsing / gist:7662879
Last active December 29, 2015 11:19
Code Paster
// Use this gist to get syntax highlighted code for use in word processors. Just preview a comment
// that contains code.