Skip to content

Instantly share code, notes, and snippets.

@izolate
Created February 23, 2016 09:11
Show Gist options
  • Save izolate/1949c8bcee14ac24b303 to your computer and use it in GitHub Desktop.
Save izolate/1949c8bcee14ac24b303 to your computer and use it in GitHub Desktop.

Revisions

  1. izolate created this gist Feb 23, 2016.
    86 changes: 86 additions & 0 deletions use-strong.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    Opt-in
    - "use strong"
    - --use-strong
    - implies strict mode

    Scoping
    - 'var' is a syntax error
    - 'function' is lexically scoped everywhere
    - unbound variables are an early reference error
    - forward reference to anything but functions or classes is an early reference error
    - only allow forward references to functions in the same group
    - only allow forward references to classes in the same group

    Objects & Arrays
    - literals create strong objects
    - rest patterns create strong arrays
    - array elisions are syntax error
    - reading a missing property is a type error
    - setting prototype is a type error
    - deleting a property is rejected
    - freezing non-configurable property is type error

    Functions & Generators
    - 'arguments' is syntax error
    - literals create strong functions/generators
    - 'function' bindings are immutable
    - functions are not constructors
    - functions have no 'prototype'
    - functions have no 'caller', 'callee', 'arguments'
    - function objects are frozen
    - too few arguments are type error

    Classes
    - "use strong" in constructor body is a syntax error
    - 'this' in constructor only for assignment [*]
    - no reference to 'this' before 'super' call in constructor
    - no reference to 'this' after 'return' in constructor
    - no 'this' assignment nested in other statement in constructor
    - no use of 'super' in constructor other than call
    - no 'super' call nested in other statement in constructor
    - no 'return' before the super call in constructor
    - no 'return' with value in constructor
    - 'null' as a super class is type error
    - 'class' bindings are immutable
    - class objects are frozen
    - class prototypes are frozen
    - inheriting from a strong class outside strong mode is a type error [*]
    - strong class constructors create strong instances [*]
    - instances of strong classes are sealed [*]

    Conversions
    - numeric operators require number
    - '+' requires both numbers or both strings
    - '++' and '--' require numbers
    - inequality requires both numbers or both strings
    - indexing requires number, string, or symbol

    Undefined
    - binding 'undefined' is syntax error outside destructuring
    - assigning to 'undefined' is syntax error outside destructuring

    Eval
    - direct 'eval' is syntax error

    Switch
    - fall-through is a syntax error
    - declaration in case block is a syntax error

    Obsoletion
    - 'for'-'in' is syntax error
    - 'delete' is a syntax error [*]
    - ==' and '!=' are syntax errors
    - dependent empty statement is syntax error

    Things that have not been finished:

    - scoping checks when using 'eval'
    - making duplicate properties in object literals an error
    - throwing when writing a missing property
    - restrictions on arrays' 'length' property
    - restrictions on arrays' non-index properties
    - making out-of-bounds indices an error for arrays and strings
    - invoking a class method on non-instances is a type error
    - libraries

    Source: https://groups.google.com/forum/#!topic/strengthen-js/ojj3TDxbHpQ