Changeset 170034 in webkit


Ignore:
Timestamp:
Jun 16, 2014 4:19:29 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Parser statementDepth accounting needs to account for when a function body excludes its braces.
<https://webkit.org/b/133832>

Reviewed by Oliver Hunt.

Source/JavaScriptCore:
In some cases (e.g. when a Function object is instantiated from a string), the
function body source may not include its braces. The parser needs to account
for this when calculating its statementDepth.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::codeBlockFor):

  • bytecode/UnlinkedCodeBlock.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseStatement):

  • Also fixed the error message for declaring nested functions in strict mode to be more accurate.
  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):
(JSC::parse):

  • runtime/Executable.cpp:

(JSC::ScriptExecutable::newCodeBlockFor):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
    • Added cases for declaring functions in strict mode.
    • Added caught error to the test result logging if it's not a SyntaxError. This helps catch the issue in this bug which was erroneously throwing RangeErrors.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r170010 r170034  
     12014-06-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Parser statementDepth accounting needs to account for when a function body excludes its braces.
     4        <https://webkit.org/b/133832>
     5
     6        Reviewed by Oliver Hunt.
     7
     8        * js/parser-syntax-check-expected.txt:
     9        * js/script-tests/parser-syntax-check.js:
     10          - Added cases for declaring functions in strict mode.
     11          - Added caught error to the test result logging if it's not a SyntaxError.
     12            This helps catch the issue in this bug which was erroneously throwing
     13            RangeErrors.
     14
    1152014-06-16  Radu Stavila  <stavila@adobe.com>
    216
  • trunk/LayoutTests/js/parser-syntax-check-expected.txt

    r166392 r170034  
    1919PASS Invalid: "a.'l'"
    2020PASS Invalid: "function f() { a.'l' }"
    21 PASS Valid:   "a: +~!new a"
     21PASS Valid:   "a: +~!new a" with ReferenceError
    2222PASS Valid:   "function f() { a: +~!new a }"
    2323PASS Invalid: "new -a"
    2424PASS Invalid: "function f() { new -a }"
    25 PASS Valid:   "new (-1)"
     25PASS Valid:   "new (-1)" with TypeError
    2626PASS Valid:   "function f() { new (-1) }"
    27 PASS Valid:   "a: b: c: new f(x++)++"
     27PASS Valid:   "a: b: c: new f(x++)++" with ReferenceError
    2828PASS Valid:   "function f() { a: b: c: new f(x++)++ }"
    29 PASS Valid:   "(a)++"
     29PASS Valid:   "(a)++" with ReferenceError
    3030PASS Valid:   "function f() { (a)++ }"
    31 PASS Valid:   "(1--).x"
     31PASS Valid:   "(1--).x" with ReferenceError
    3232PASS Valid:   "function f() { (1--).x }"
    3333PASS Invalid: "a-- ++"
     
    3535PASS Invalid: "(a:) --b"
    3636PASS Invalid: "function f() { (a:) --b }"
    37 PASS Valid:   "++ -- ++ a"
     37PASS Valid:   "++ -- ++ a" with ReferenceError
    3838PASS Valid:   "function f() { ++ -- ++ a }"
    39 PASS Valid:   "++ new new a ++"
     39PASS Valid:   "++ new new a ++" with ReferenceError
    4040PASS Valid:   "function f() { ++ new new a ++ }"
    4141PASS Valid:   "delete void 0"
     
    4545PASS Invalid: "(a++"
    4646PASS Invalid: "function f() { (a++ }"
    47 PASS Valid:   "++a--"
     47PASS Valid:   "++a--" with ReferenceError
    4848PASS Valid:   "function f() { ++a-- }"
    49 PASS Valid:   "++((a))--"
     49PASS Valid:   "++((a))--" with ReferenceError
    5050PASS Valid:   "function f() { ++((a))-- }"
    51 PASS Valid:   "(a.x++)++"
     51PASS Valid:   "(a.x++)++" with ReferenceError
    5252PASS Valid:   "function f() { (a.x++)++ }"
    5353PASS Invalid: "1: null"
     
    6868PASS Valid:   "function f() { 1 .l }"
    6969Binary and conditional operators
    70 PASS Valid:   "a + + typeof this"
     70PASS Valid:   "a + + typeof this" with ReferenceError
    7171PASS Valid:   "function f() { a + + typeof this }"
    7272PASS Invalid: "a + * b"
     
    8080PASS Invalid: "a-"
    8181PASS Invalid: "function f() { a- }"
    82 PASS Valid:   "a = b ? b = c : d = e"
     82PASS Valid:   "a = b ? b = c : d = e" with ReferenceError
    8383PASS Valid:   "function f() { a = b ? b = c : d = e }"
    84 PASS Valid:   "s: a[1].l ? b.l['s'] ? c++ : d : true"
     84PASS Valid:   "s: a[1].l ? b.l['s'] ? c++ : d : true" with ReferenceError
    8585PASS Valid:   "function f() { s: a[1].l ? b.l['s'] ? c++ : d : true }"
    86 PASS Valid:   "a ? b + 1 ? c + 3 * d.l : d[5][6] : e"
     86PASS Valid:   "a ? b + 1 ? c + 3 * d.l : d[5][6] : e" with ReferenceError
    8787PASS Valid:   "function f() { a ? b + 1 ? c + 3 * d.l : d[5][6] : e }"
    88 PASS Valid:   "a in b instanceof delete -c"
     88PASS Valid:   "a in b instanceof delete -c" with ReferenceError
    8989PASS Valid:   "function f() { a in b instanceof delete -c }"
    9090PASS Invalid: "a in instanceof b.l"
     
    9494PASS Invalid: "- false = 3"
    9595PASS Invalid: "function f() { - false = 3 }"
    96 PASS Valid:   "a: b: c: (1 + null) = 3"
     96PASS Valid:   "a: b: c: (1 + null) = 3" with ReferenceError
    9797PASS Valid:   "function f() { a: b: c: (1 + null) = 3 }"
    98 PASS Valid:   "a[2] = b.l += c /= 4 * 7 ^ !6"
     98PASS Valid:   "a[2] = b.l += c /= 4 * 7 ^ !6" with ReferenceError
    9999PASS Valid:   "function f() { a[2] = b.l += c /= 4 * 7 ^ !6 }"
    100100PASS Invalid: "a + typeof b += c in d"
     
    102102PASS Invalid: "typeof a &= typeof b"
    103103PASS Invalid: "function f() { typeof a &= typeof b }"
    104 PASS Valid:   "a: ((typeof (a))) >>>= a || b.l && c"
     104PASS Valid:   "a: ((typeof (a))) >>>= a || b.l && c" with ReferenceError
    105105PASS Valid:   "function f() { a: ((typeof (a))) >>>= a || b.l && c }"
    106 PASS Valid:   "a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g"
     106PASS Valid:   "a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g" with ReferenceError
    107107PASS Valid:   "function f() { a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g }"
    108 PASS Valid:   "-void+x['y'].l == x.l != 5 - f[7]"
     108PASS Valid:   "-void+x['y'].l == x.l != 5 - f[7]" with ReferenceError
    109109PASS Valid:   "function f() { -void+x['y'].l == x.l != 5 - f[7] }"
    110110Function calls (and new with arguments)
    111 PASS Valid:   "a()()()"
     111PASS Valid:   "a()()()" with ReferenceError
    112112PASS Valid:   "function f() { a()()() }"
    113 PASS Valid:   "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)"
     113PASS Valid:   "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)" with ReferenceError
    114114PASS Valid:   "function f() { s: l: a[2](4 == 6, 5 = 6)(f[4], 6) }"
    115 PASS Valid:   "s: eval(a.apply(), b.call(c[5] - f[7]))"
     115PASS Valid:   "s: eval(a.apply(), b.call(c[5] - f[7]))" with ReferenceError
    116116PASS Valid:   "function f() { s: eval(a.apply(), b.call(c[5] - f[7])) }"
    117117PASS Invalid: "a("
     
    125125PASS Invalid: "a(5,6"
    126126PASS Invalid: "function f() { a(5,6 }"
    127 PASS Valid:   "a(b[7], c <d> e.l, new a() > b)"
     127PASS Valid:   "a(b[7], c <d> e.l, new a() > b)" with ReferenceError
    128128PASS Valid:   "function f() { a(b[7], c <d> e.l, new a() > b) }"
    129129PASS Invalid: "a(b[5)"
     
    131131PASS Invalid: "a(b.)"
    132132PASS Invalid: "function f() { a(b.) }"
    133 PASS Valid:   "~new new a(1)(i++)(c[l])"
     133PASS Valid:   "~new new a(1)(i++)(c[l])" with ReferenceError
    134134PASS Valid:   "function f() { ~new new a(1)(i++)(c[l]) }"
    135135PASS Invalid: "a(*a)"
    136136PASS Invalid: "function f() { a(*a) }"
    137 PASS Valid:   "((((a))((b)()).l))()"
     137PASS Valid:   "((((a))((b)()).l))()" with ReferenceError
    138138PASS Valid:   "function f() { ((((a))((b)()).l))() }"
    139 PASS Valid:   "(a)[b + (c) / (d())].l--"
     139PASS Valid:   "(a)[b + (c) / (d())].l--" with ReferenceError
    140140PASS Valid:   "function f() { (a)[b + (c) / (d())].l-- }"
    141 PASS Valid:   "new (5)"
     141PASS Valid:   "new (5)" with TypeError
    142142PASS Valid:   "function f() { new (5) }"
    143143PASS Invalid: "new a(5"
    144144PASS Invalid: "function f() { new a(5 }"
    145 PASS Valid:   "new (f + 5)(6, (g)() - 'l'() - true(false))"
     145PASS Valid:   "new (f + 5)(6, (g)() - 'l'() - true(false))" with ReferenceError
    146146PASS Valid:   "function f() { new (f + 5)(6, (g)() - 'l'() - true(false)) }"
    147147PASS Invalid: "a(.length)"
     
    170170PASS Invalid: "(function this(){})"
    171171PASS Invalid: "function f() { (function this(){}) }"
    172 PASS Valid:   "(delete new function f(){} + function(a,b){}(5)(6))"
     172PASS Valid:   "(delete new function f(){} + function(a,b){}(5)(6))" with TypeError
    173173PASS Valid:   "function f() { (delete new function f(){} + function(a,b){}(5)(6)) }"
    174174PASS Valid:   "6 - function (m) { function g() {} }"
     
    179179PASS Invalid: "function f() { function l++(){} }"
    180180Array and object literal, comma operator
    181 PASS Valid:   "[] in [5,6] * [,5,] / [,,5,,] || [a,] && new [,b] % [,,]"
     181PASS Valid:   "[] in [5,6] * [,5,] / [,,5,,] || [a,] && new [,b] % [,,]" with TypeError
    182182PASS Valid:   "function f() { [] in [5,6] * [,5,] / [,,5,,] || [a,] && new [,b] % [,,] }"
    183183PASS Invalid: "[5,"
     
    187187PASS Invalid: "(a,)"
    188188PASS Invalid: "function f() { (a,) }"
    189 PASS Valid:   "1 + {get get(){}, set set(a){}, get1:4, set1:get-set, }"
     189PASS Valid:   "1 + {get get(){}, set set(a){}, get1:4, set1:get-set, }" with ReferenceError
    190190PASS Valid:   "function f() { 1 + {get get(){}, set set(a){}, get1:4, set1:get-set, } }"
    191191PASS Invalid: "1 + {a"
     
    197197PASS Invalid: ",a"
    198198PASS Invalid: "function f() { ,a }"
    199 PASS Valid:   "(4,(5,a(3,4))),f[4,a-6]"
     199PASS Valid:   "(4,(5,a(3,4))),f[4,a-6]" with ReferenceError
    200200PASS Valid:   "function f() { (4,(5,a(3,4))),f[4,a-6] }"
    201201PASS Invalid: "(,f)"
     
    216216PASS Invalid: "{ a: }"
    217217PASS Invalid: "function f() { { a: } }"
    218 PASS Valid:   "{} f; { 6 + f() }"
     218PASS Valid:   "{} f; { 6 + f() }" with ReferenceError
    219219PASS Valid:   "function f() { {} f; { 6 + f() } }"
    220 PASS Valid:   "{ a[5],6; {} ++b-new (-5)() } c().l++"
     220PASS Valid:   "{ a[5],6; {} ++b-new (-5)() } c().l++" with ReferenceError
    221221PASS Valid:   "function f() { { a[5],6; {} ++b-new (-5)() } c().l++ }"
    222 PASS Valid:   "{ l1: l2: l3: { this } a = 32 ; { i++ ; { { { } } ++i } } }"
     222PASS Valid:   "{ l1: l2: l3: { this } a = 32 ; { i++ ; { { { } } ++i } } }" with ReferenceError
    223223PASS Valid:   "function f() { { l1: l2: l3: { this } a = 32 ; { i++ ; { { { } } ++i } } } }"
    224224PASS Valid:   "if (a) ;"
     
    236236PASS Invalid: "else {}"
    237237PASS Invalid: "function f() { else {} }"
    238 PASS Valid:   "if (a) if (b) y; else {} else ;"
     238PASS Valid:   "if (a) if (b) y; else {} else ;" with ReferenceError
    239239PASS Valid:   "function f() { if (a) if (b) y; else {} else ; }"
    240240PASS Invalid: "if (a) {} else x; else"
     
    242242PASS Invalid: "if (a) { else }"
    243243PASS Invalid: "function f() { if (a) { else } }"
    244 PASS Valid:   "if (a.l + new b()) 4 + 5 - f()"
     244PASS Valid:   "if (a.l + new b()) 4 + 5 - f()" with ReferenceError
    245245PASS Valid:   "function f() { if (a.l + new b()) 4 + 5 - f() }"
    246 PASS Valid:   "if (a) with (x) ; else with (y) ;"
     246PASS Valid:   "if (a) with (x) ; else with (y) ;" with ReferenceError
    247247PASS Valid:   "function f() { if (a) with (x) ; else with (y) ; }"
    248248PASS Invalid: "with a.b { }"
    249249PASS Invalid: "function f() { with a.b { } }"
    250 PASS Valid:   "while (a() - new b) ;"
     250PASS Valid:   "while (a() - new b) ;" with TypeError
    251251PASS Valid:   "function f() { while (a() - new b) ; }"
    252252PASS Invalid: "while a {}"
    253253PASS Invalid: "function f() { while a {} }"
    254 PASS Valid:   "do ; while(0) i++"
     254PASS Valid:   "do ; while(0) i++" with ReferenceError
    255255PASS Valid:   "function f() { do ; while(0) i++ }"
    256 PASS Valid:   "do if (a) x; else y; while(z)"
     256PASS Valid:   "do if (a) x; else y; while(z)" with ReferenceError
    257257PASS Valid:   "function f() { do if (a) x; else y; while(z) }"
    258258PASS Invalid: "do g; while 4"
     
    264264PASS Valid:   "do while (0) if (a) {} else y; while(0)"
    265265PASS Valid:   "function f() { do while (0) if (a) {} else y; while(0) }"
    266 PASS Valid:   "if (a) while (b) if (c) with(d) {} else e; else f"
     266PASS Valid:   "if (a) while (b) if (c) with(d) {} else e; else f" with ReferenceError
    267267PASS Valid:   "function f() { if (a) while (b) if (c) with(d) {} else e; else f }"
    268268PASS Invalid: "break ; break your_limits ; continue ; continue living ; debugger"
     
    278278PASS Valid:   "while (1) break"
    279279PASS Valid:   "function f() { while (1) break }"
    280 PASS Valid:   "do if (a) with (b) continue; else debugger; while (false)"
     280PASS Valid:   "do if (a) with (b) continue; else debugger; while (false)" with ReferenceError
    281281PASS Valid:   "function f() { do if (a) with (b) continue; else debugger; while (false) }"
    282282PASS Invalid: "do if (a) while (false) else debugger"
     
    286286PASS Valid:   "if (a) function f() {} else function g() {}"
    287287PASS Valid:   "function f() { if (a) function f() {} else function g() {} }"
    288 PASS Valid:   "if (a()) while(0) function f() {} else function g() {}"
     288PASS Valid:   "if (a()) while(0) function f() {} else function g() {}" with TypeError
    289289PASS Valid:   "function f() { if (a()) while(0) function f() {} else function g() {} }"
    290290PASS Invalid: "if (a()) function f() { else function g() }"
     
    294294PASS Invalid: "if (a) if (b) ; else function (){}"
    295295PASS Invalid: "function f() { if (a) if (b) ; else function (){} }"
    296 PASS Valid:   "throw a"
     296PASS Valid:   "throw a" with 32
    297297PASS Valid:   "function f() { throw a }"
    298 PASS Valid:   "throw a + b in void c"
     298PASS Valid:   "throw a + b in void c" with ReferenceError
    299299PASS Valid:   "function f() { throw a + b in void c }"
    300300PASS Invalid: "throw"
     
    321321PASS Invalid: "var a = var b"
    322322PASS Invalid: "function f() { var a = var b }"
    323 PASS Valid:   "const a = b += c, a, a, a = (b - f())"
     323PASS Valid:   "const a = b += c, a, a, a = (b - f())" with ReferenceError
    324324PASS Valid:   "function f() { const a = b += c, a, a, a = (b - f()) }"
    325325PASS Invalid: "var a %= b | 5"
     
    333333PASS Invalid: "var var = 3"
    334334PASS Invalid: "function f() { var var = 3 }"
    335 PASS Valid:   "var varr = 3 in 1"
     335PASS Valid:   "var varr = 3 in 1" with TypeError
    336336PASS Valid:   "function f() { var varr = 3 in 1 }"
    337337PASS Valid:   "const a, a, a = void 7 - typeof 8, a = 8"
    338338PASS Valid:   "function f() { const a, a, a = void 7 - typeof 8, a = 8 }"
    339 PASS Valid:   "const x_x = 6 /= 7 ? e : f"
     339PASS Valid:   "const x_x = 6 /= 7 ? e : f" with ReferenceError
    340340PASS Valid:   "function f() { const x_x = 6 /= 7 ? e : f }"
    341341PASS Invalid: "var a = ?"
     
    345345PASS Invalid: "var a = :)"
    346346PASS Invalid: "function f() { var a = :) }"
    347 PASS Valid:   "var a = a in b in c instanceof d"
     347PASS Valid:   "var a = a in b in c instanceof d" with ReferenceError
    348348PASS Valid:   "function f() { var a = a in b in c instanceof d }"
    349349PASS Invalid: "var a = b ? c, b"
     
    408408PASS Valid:   "for (var a = b, b = a ; ; ) break"
    409409PASS Valid:   "function f() { for (var a = b, b = a ; ; ) break }"
    410 PASS Valid:   "for (var a = b, c, d, b = a ; x in b ; ) { break }"
     410PASS Valid:   "for (var a = b, c, d, b = a ; x in b ; ) { break }" with ReferenceError
    411411PASS Valid:   "function f() { for (var a = b, c, d, b = a ; x in b ; ) { break } }"
    412 PASS Valid:   "for (var a = b, c, d ; ; 1 in a()) break"
     412PASS Valid:   "for (var a = b, c, d ; ; 1 in a()) break" with ReferenceError
    413413PASS Valid:   "function f() { for (var a = b, c, d ; ; 1 in a()) break }"
    414414PASS Invalid: "for ( ; var a ; ) break"
     
    418418PASS Invalid: "for ( %a ; ; ) { }"
    419419PASS Invalid: "function f() { for ( %a ; ; ) { } }"
    420 PASS Valid:   "for (a in b) break"
     420PASS Valid:   "for (a in b) break" with ReferenceError
    421421PASS Valid:   "function f() { for (a in b) break }"
    422 PASS Valid:   "for (a() in b) break"
     422PASS Valid:   "for (a() in b) break" with ReferenceError
    423423PASS Valid:   "function f() { for (a() in b) break }"
    424 PASS Valid:   "for (a().l[4] in b) break"
     424PASS Valid:   "for (a().l[4] in b) break" with ReferenceError
    425425PASS Valid:   "function f() { for (a().l[4] in b) break }"
    426 PASS Valid:   "for (new a in b in c in d) break"
     426PASS Valid:   "for (new a in b in c in d) break" with ReferenceError
    427427PASS Valid:   "function f() { for (new a in b in c in d) break }"
    428 PASS Valid:   "for (new new new a in b) break"
     428PASS Valid:   "for (new new new a in b) break" with ReferenceError
    429429PASS Valid:   "function f() { for (new new new a in b) break }"
    430430PASS Invalid: "for (delete new a() in b) break"
     
    432432PASS Invalid: "for (a * a in b) break"
    433433PASS Invalid: "function f() { for (a * a in b) break }"
    434 PASS Valid:   "for ((a * a) in b) break"
     434PASS Valid:   "for ((a * a) in b) break" with ReferenceError
    435435PASS Valid:   "function f() { for ((a * a) in b) break }"
    436436PASS Invalid: "for (a++ in b) break"
    437437PASS Invalid: "function f() { for (a++ in b) break }"
    438 PASS Valid:   "for ((a++) in b) break"
     438PASS Valid:   "for ((a++) in b) break" with ReferenceError
    439439PASS Valid:   "function f() { for ((a++) in b) break }"
    440440PASS Invalid: "for (++a in b) break"
    441441PASS Invalid: "function f() { for (++a in b) break }"
    442 PASS Valid:   "for ((++a) in b) break"
     442PASS Valid:   "for ((++a) in b) break" with ReferenceError
    443443PASS Valid:   "function f() { for ((++a) in b) break }"
    444444PASS Invalid: "for (a, b in c) break"
     
    446446PASS Invalid: "for (a,b in c ;;) break"
    447447PASS Invalid: "function f() { for (a,b in c ;;) break }"
    448 PASS Valid:   "for (a,(b in c) ;;) break"
     448PASS Valid:   "for (a,(b in c) ;;) break" with ReferenceError
    449449PASS Valid:   "function f() { for (a,(b in c) ;;) break }"
    450 PASS Valid:   "for ((a, b) in c) break"
     450PASS Valid:   "for ((a, b) in c) break" with ReferenceError
    451451PASS Valid:   "function f() { for ((a, b) in c) break }"
    452452PASS Invalid: "for (a ? b : c in c) break"
    453453PASS Invalid: "function f() { for (a ? b : c in c) break }"
    454 PASS Valid:   "for ((a ? b : c) in c) break"
     454PASS Valid:   "for ((a ? b : c) in c) break" with ReferenceError
    455455PASS Valid:   "function f() { for ((a ? b : c) in c) break }"
    456 PASS Valid:   "for (var a in b in c) break"
     456PASS Valid:   "for (var a in b in c) break" with ReferenceError
    457457PASS Valid:   "function f() { for (var a in b in c) break }"
    458 PASS Valid:   "for (var a = 5 += 6 in b) break"
     458PASS Valid:   "for (var a = 5 += 6 in b) break" with ReferenceError
    459459PASS Valid:   "function f() { for (var a = 5 += 6 in b) break }"
    460 PASS Valid:   "for (var a = debug('should not be hit') in b) break"
     460PASS Valid:   "for (var a = debug('should not be hit') in b) break" with ReferenceError
    461461PASS Valid:   "function f() { for (var a = debug('should not be hit') in b) break }"
    462462PASS Invalid: "for (var a += 5 in b) break"
     
    470470PASS Invalid: "for (var a, b = 8 in b) break"
    471471PASS Invalid: "function f() { for (var a, b = 8 in b) break }"
    472 PASS Valid:   "for (var a = (b in c) in d) break"
     472PASS Valid:   "for (var a = (b in c) in d) break" with ReferenceError
    473473PASS Valid:   "function f() { for (var a = (b in c) in d) break }"
    474474PASS Invalid: "for (var a = (b in c in d) break"
     
    476476PASS Invalid: "for (var (a) in b) { }"
    477477PASS Invalid: "function f() { for (var (a) in b) { } }"
    478 PASS Valid:   "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
     478PASS Valid:   "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}" with ReferenceError
    479479PASS Valid:   "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
    480480try statement
    481481PASS Invalid: "try { break } catch(e) {}"
    482482PASS Invalid: "function f() { try { break } catch(e) {} }"
    483 PASS Valid:   "try {} finally { c++ }"
     483PASS Valid:   "try {} finally { c++ }" with ReferenceError
    484484PASS Valid:   "function f() { try {} finally { c++ } }"
    485485PASS Valid:   "try { with (x) { } } catch(e) {} finally { if (a) ; }"
     
    509509PASS Valid:   "if (a) try {} finally {} else b;"
    510510PASS Valid:   "function f() { if (a) try {} finally {} else b; }"
    511 PASS Valid:   "if (--a()) do with(1) try {} catch(ke) { f() ; g() } while (a in b) else {}"
     511PASS Valid:   "if (--a()) do with(1) try {} catch(ke) { f() ; g() } while (a in b) else {}" with ReferenceError
    512512PASS Valid:   "function f() { if (--a()) do with(1) try {} catch(ke) { f() ; g() } while (a in b) else {} }"
    513513PASS Invalid: "if (a) try {} else b; catch (e) { }"
     
    528528PASS Invalid: "switch (a) case 3: b;"
    529529PASS Invalid: "function f() { switch (a) case 3: b; }"
    530 PASS Valid:   "switch (f()) { case 5 * f(): default: case '6' - 9: ++i }"
     530PASS Valid:   "switch (f()) { case 5 * f(): default: case '6' - 9: ++i }" with ReferenceError
    531531PASS Valid:   "function f() { switch (f()) { case 5 * f(): default: case '6' - 9: ++i } }"
    532532PASS Invalid: "switch (true) { default: case 6: default: }"
     
    536536PASS Invalid: "switch (l) { case 1: ; a: case 5: }"
    537537PASS Invalid: "function f() { switch (l) { case 1: ; a: case 5: } }"
    538 PASS Valid:   "switch (g() - h[5].l) { case 1 + 6: a: b: c: ++f }"
     538PASS Valid:   "switch (g() - h[5].l) { case 1 + 6: a: b: c: ++f }" with ReferenceError
    539539PASS Valid:   "function f() { switch (g() - h[5].l) { case 1 + 6: a: b: c: ++f } }"
    540540PASS Invalid: "switch (g) { case 1: a: }"
     
    546546PASS Invalid: "switch (g) { case 1:"
    547547PASS Invalid: "function f() { switch (g) { case 1: }"
    548 PASS Valid:   "switch (l) { case a = b ? c : d : }"
     548PASS Valid:   "switch (l) { case a = b ? c : d : }" with ReferenceError
    549549PASS Valid:   "function f() { switch (l) { case a = b ? c : d : } }"
    550 PASS Valid:   "switch (sw) { case a ? b - 7[1] ? [c,,] : d = 6 : { } : }"
     550PASS Valid:   "switch (sw) { case a ? b - 7[1] ? [c,,] : d = 6 : { } : }" with ReferenceError
    551551PASS Valid:   "function f() { switch (sw) { case a ? b - 7[1] ? [c,,] : d = 6 : { } : } }"
    552552PASS Invalid: "switch (l) { case b ? c : }"
    553553PASS Invalid: "function f() { switch (l) { case b ? c : } }"
    554 PASS Valid:   "switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default: }"
     554PASS Valid:   "switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default: }" with ReferenceError
    555555PASS Valid:   "function f() { switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default: } }"
    556556PASS Invalid: "switch (4 - ) { }"
     
    576576PASS Valid:   "'use strict'; (function __proto__(){})"
    577577PASS Valid:   "function f() { 'use strict'; (function __proto__(){}) }"
     578PASS Valid:   "'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } f1(5);"
     579PASS Valid:   "function f() { 'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } f1(5); }"
     580PASS Valid:   "'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } f1(5);"
     581PASS Valid:   "function f() { 'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } f1(5); }"
     582PASS Invalid: "'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } f1(5);"
     583PASS Invalid: "function f() { 'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } f1(5); }"
     584PASS Invalid: "'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } f1(5);"
     585PASS Invalid: "function f() { 'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } f1(5); }"
     586PASS Valid:   "var str = "'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5);"
     587PASS Valid:   "function f() { var str = "'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5); }"
     588PASS Valid:   "var str = "'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5);"
     589PASS Valid:   "function f() { var str = "'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5); }"
     590PASS Invalid: "var str = "'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } return f1(arguments[0]);"; var foo = new Function(str); foo(5);"
     591FAIL Invalid: "function f() { var str = "'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } return f1(arguments[0]);"; var foo = new Function(str); foo(5); }" but did not throw
     592PASS Invalid: "var str = "'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5);"
     593FAIL Invalid: "function f() { var str = "'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } return f1(arguments[0]);"; var foo = new Function(str); foo(5); }" but did not throw
    578594PASS Valid:   "if (0) $foo; "
    579595PASS Valid:   "function f() { if (0) $foo;  }"
     
    606622PASS Invalid: "var a.b;"
    607623PASS Invalid: "function f() { var a.b; }"
    608 PASS Valid:   "for (of of of){}"
     624PASS Valid:   "for (of of of){}" with ReferenceError
    609625PASS Valid:   "function f() { for (of of of){} }"
    610 PASS Valid:   "for (of; of; of){}"
     626PASS Valid:   "for (of; of; of){}" with ReferenceError
    611627PASS Valid:   "function f() { for (of; of; of){} }"
    612 PASS Valid:   "for (var of of of){}"
     628PASS Valid:   "for (var of of of){}" with TypeError
    613629PASS Valid:   "function f() { for (var of of of){} }"
    614630PASS Valid:   "for (var of; of; of){}"
     
    618634PASS Invalid: "for (var of[of] of of){}"
    619635PASS Invalid: "function f() { for (var of[of] of of){} }"
    620 PASS Valid:   "for (of.of of of){}"
     636PASS Valid:   "for (of.of of of){}" with ReferenceError
    621637PASS Valid:   "function f() { for (of.of of of){} }"
    622 PASS Valid:   "for (of[of] of of){}"
     638PASS Valid:   "for (of[of] of of){}" with ReferenceError
    623639PASS Valid:   "function f() { for (of[of] of of){} }"
    624 PASS Valid:   "for (var [of] of of){}"
     640PASS Valid:   "for (var [of] of of){}" with TypeError
    625641PASS Valid:   "function f() { for (var [of] of of){} }"
    626 PASS Valid:   "for (var {of} of of){}"
     642PASS Valid:   "for (var {of} of of){}" with TypeError
    627643PASS Valid:   "function f() { for (var {of} of of){} }"
    628 PASS Valid:   "for (of in of){}"
     644PASS Valid:   "for (of in of){}" with ReferenceError
    629645PASS Valid:   "function f() { for (of in of){} }"
    630646PASS Valid:   "for (var of in of){}"
     
    632648PASS Invalid: "for (var of.of in of){}"
    633649PASS Invalid: "function f() { for (var of.of in of){} }"
    634 PASS Valid:   "for (of.of in of){}"
     650PASS Valid:   "for (of.of in of){}" with ReferenceError
    635651PASS Valid:   "function f() { for (of.of in of){} }"
    636 PASS Valid:   "for (of[of] in of){}"
     652PASS Valid:   "for (of[of] in of){}" with ReferenceError
    637653PASS Valid:   "function f() { for (of[of] in of){} }"
    638654PASS Invalid: "for (var of[of] in of){}"
     
    642658PASS Valid:   "for (var {of} in of){}"
    643659PASS Valid:   "function f() { for (var {of} in of){} }"
    644 PASS Valid:   "for ([of] in of){}"
     660PASS Valid:   "for ([of] in of){}" with ReferenceError
    645661PASS Valid:   "function f() { for ([of] in of){} }"
    646 PASS Valid:   "for ({of} in of){}"
     662PASS Valid:   "for ({of} in of){}" with ReferenceError
    647663PASS Valid:   "function f() { for ({of} in of){} }"
    648664PASS Invalid: "for (of of of of){}"
     
    663679PASS Invalid: "function f() { for (var of in){} }"
    664680spread operator
    665 PASS Valid:   "foo(...bar)"
     681PASS Valid:   "foo(...bar)" with ReferenceError
    666682PASS Valid:   "function f() { foo(...bar) }"
    667 PASS Valid:   "o.foo(...bar)"
     683PASS Valid:   "o.foo(...bar)" with ReferenceError
    668684PASS Valid:   "function f() { o.foo(...bar) }"
    669 PASS Valid:   "o[foo](...bar)"
     685PASS Valid:   "o[foo](...bar)" with ReferenceError
    670686PASS Valid:   "function f() { o[foo](...bar) }"
    671 PASS Valid:   "new foo(...bar)"
     687PASS Valid:   "new foo(...bar)" with ReferenceError
    672688PASS Valid:   "function f() { new foo(...bar) }"
    673 PASS Valid:   "new o.foo(...bar)"
     689PASS Valid:   "new o.foo(...bar)" with ReferenceError
    674690PASS Valid:   "function f() { new o.foo(...bar) }"
    675 PASS Valid:   "new o[foo](...bar)"
     691PASS Valid:   "new o[foo](...bar)" with ReferenceError
    676692PASS Valid:   "function f() { new o[foo](...bar) }"
    677693PASS Invalid: "foo(...)"
     
    699715PASS Invalid: "o[foo](...bar, a)"
    700716PASS Invalid: "function f() { o[foo](...bar, a) }"
    701 PASS Valid:   "[...bar]"
     717PASS Valid:   "[...bar]" with ReferenceError
    702718PASS Valid:   "function f() { [...bar] }"
    703 PASS Valid:   "[a, ...bar]"
     719PASS Valid:   "[a, ...bar]" with ReferenceError
    704720PASS Valid:   "function f() { [a, ...bar] }"
    705 PASS Valid:   "[...bar, a]"
     721PASS Valid:   "[...bar, a]" with ReferenceError
    706722PASS Valid:   "function f() { [...bar, a] }"
    707 PASS Valid:   "[...bar,,,,]"
     723PASS Valid:   "[...bar,,,,]" with ReferenceError
    708724PASS Valid:   "function f() { [...bar,,,,] }"
    709 PASS Valid:   "[,,,,...bar]"
     725PASS Valid:   "[,,,,...bar]" with ReferenceError
    710726PASS Valid:   "function f() { [,,,,...bar] }"
    711 PASS Valid:   "({1: x})"
     727PASS Valid:   "({1: x})" with ReferenceError
    712728PASS Valid:   "function f() { ({1: x}) }"
    713729PASS Valid:   "({1: x}=1)"
    714730PASS Valid:   "function f() { ({1: x}=1) }"
    715 PASS Valid:   "({1: x}=null)"
     731PASS Valid:   "({1: x}=null)" with TypeError
    716732PASS Valid:   "function f() { ({1: x}=null) }"
    717733PASS Valid:   "({1: x})"
     
    719735PASS Valid:   "({1: x}=1)"
    720736PASS Valid:   "function f() { ({1: x}=1) }"
    721 PASS Valid:   "({1: x}=null)"
     737PASS Valid:   "({1: x}=null)" with TypeError
    722738PASS Valid:   "function f() { ({1: x}=null) }"
    723 PASS Valid:   "({a: b}=null)"
     739PASS Valid:   "({a: b}=null)" with TypeError
    724740PASS Valid:   "function f() { ({a: b}=null) }"
    725741PASS Valid:   "'use strict'; ({1: x})"
     
    727743PASS Valid:   "'use strict'; ({1: x}=1)"
    728744PASS Valid:   "function f() { 'use strict'; ({1: x}=1) }"
    729 PASS Valid:   "'use strict'; ({1: x}=null)"
     745PASS Valid:   "'use strict'; ({1: x}=null)" with TypeError
    730746PASS Valid:   "function f() { 'use strict'; ({1: x}=null) }"
    731 PASS Valid:   "'use strict'; ({a: b}=null)"
     747PASS Valid:   "'use strict'; ({a: b}=null)" with TypeError
    732748PASS Valid:   "function f() { 'use strict'; ({a: b}=null) }"
    733749PASS Valid:   "var {1:x}=1"
     
    743759PASS Valid:   "delete ({a:a}=1)"
    744760PASS Valid:   "function f() { delete ({a:a}=1) }"
    745 PASS Valid:   "({a}=1)()"
     761PASS Valid:   "({a}=1)()" with TypeError
    746762PASS Valid:   "function f() { ({a}=1)() }"
    747 PASS Valid:   "({a:a}=1)()"
     763PASS Valid:   "({a:a}=1)()" with TypeError
    748764PASS Valid:   "function f() { ({a:a}=1)() }"
    749 PASS Valid:   "({a}=1)=1"
     765PASS Valid:   "({a}=1)=1" with ReferenceError
    750766PASS Valid:   "function f() { ({a}=1)=1 }"
    751 PASS Valid:   "({a:a}=1)=1"
     767PASS Valid:   "({a:a}=1)=1" with ReferenceError
    752768PASS Valid:   "function f() { ({a:a}=1)=1 }"
    753 PASS Valid:   "({a}=1=1)"
     769PASS Valid:   "({a}=1=1)" with ReferenceError
    754770PASS Valid:   "function f() { ({a}=1=1) }"
    755 PASS Valid:   "({a:a}=1=1)"
     771PASS Valid:   "({a:a}=1=1)" with ReferenceError
    756772PASS Valid:   "function f() { ({a:a}=1=1) }"
    757773PASS Invalid: "({get [x](){}})"
  • trunk/LayoutTests/js/script-tests/parser-syntax-check.js

    r166392 r170034  
    33);
    44
    5 function runTest(_a, errorType)
     5function runTest(_a, expectSyntaxError)
    66{
    7     var success;
     7    var error;
     8
    89    if (typeof _a != "string")
    910        testFailed("runTest expects string argument: " + _a);
    1011    try {
    1112        eval(_a);
    12         success = true;
    1313    } catch (e) {
    14         success = !(e instanceof SyntaxError);
     14        error = e;
    1515    }
    16     if ((!!errorType) == !success) {
    17         if (errorType)
     16
     17    if (expectSyntaxError) {
     18        if (error && error instanceof SyntaxError)
    1819            testPassed('Invalid: "' + _a + '"');
     20        else if (error)
     21            testFailed('Invalid: "' + _a + '" should throw SyntaxError but got ' + (error.name || error));
    1922        else
     23            testFailed('Invalid: "' + _a + '" but did not throw');
     24    } else {
     25        if (!error)
    2026            testPassed('Valid:   "' + _a + '"');
    21     } else {
    22         if (errorType)
    23             testFailed('Invalid: "' + _a + '" should throw ' + errorType.name);
     27        else if (!(error instanceof SyntaxError))
     28            testPassed('Valid:   "' + _a + '" with ' + (error.name || error));
    2429        else
    25             testFailed('Valid:   "' + _a + '" should NOT throw ');
     30            testFailed('Valid:   "' + _a + '" should NOT throw but got ' + (error.name || error));
    2631    }
    2732}
     
    3439}
    3540
    36 function invalid(_a, _type)
     41function invalid(_a)
    3742{
    38     _type = _type || SyntaxError;
    3943    // Test both the grammar and the syntax checker
    4044    runTest(_a, true);
     
    366370valid("'use strict'; function __proto__(){}")
    367371valid("'use strict'; (function __proto__(){})")
     372
     373valid("'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } f1(5);")
     374valid("'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } f1(5);")
     375invalid("'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } f1(5);")
     376invalid("'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } f1(5);")
     377
     378valid("var str = \"'use strict'; function f1(a) { function f2(b) { return b; } return f2(a); } return f1(arguments[0]);\"; var foo = new Function(str); foo(5);")
     379valid("var str = \"'use strict'; function f1(a) { function f2(b) { function f3(c) { return c; } return f3(b); } return f2(a); } return f1(arguments[0]);\"; var foo = new Function(str); foo(5);")
     380invalid("var str = \"'use strict'; function f1(a) { if (a) { function f2(b) { return b; } return f2(a); } else return a; } return f1(arguments[0]);\"; var foo = new Function(str); foo(5);", SyntaxError, undefined)
     381invalid("var str = \"'use strict'; function f1(a) { function f2(b) { if (b) { function f3(c) { return c; } return f3(b); } else return b; } return f2(a); } return f1(arguments[0]);\"; var foo = new Function(str); foo(5);", SyntaxError, undefined)
    368382
    369383valid("if (0) $foo; ")
  • trunk/Source/JavaScriptCore/ChangeLog

    r170022 r170034  
     12014-06-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Parser statementDepth accounting needs to account for when a function body excludes its braces.
     4        <https://webkit.org/b/133832>
     5
     6        Reviewed by Oliver Hunt.
     7
     8        In some cases (e.g. when a Function object is instantiated from a string), the
     9        function body source may not include its braces.  The parser needs to account
     10        for this when calculating its statementDepth.
     11
     12        * bytecode/UnlinkedCodeBlock.cpp:
     13        (JSC::generateFunctionCodeBlock):
     14        (JSC::UnlinkedFunctionExecutable::codeBlockFor):
     15        * bytecode/UnlinkedCodeBlock.h:
     16        * parser/Parser.cpp:
     17        (JSC::Parser<LexerType>::parseStatement):
     18        - Also fixed the error message for declaring nested functions in strict mode
     19          to be more accurate.
     20        * parser/Parser.h:
     21        (JSC::Parser<LexerType>::parse):
     22        (JSC::parse):
     23        * runtime/Executable.cpp:
     24        (JSC::ScriptExecutable::newCodeBlockFor):
     25
    1262014-06-16  Juergen Ributzka  <juergen@apple.com>
    227
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r169920 r170034  
    5050const ClassInfo UnlinkedFunctionCodeBlock::s_info = { "UnlinkedFunctionCodeBlock", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(UnlinkedFunctionCodeBlock) };
    5151
    52 static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error)
    53 {
    54     RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error);
     52static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, bool bodyIncludesBraces, ParserError& error)
     53{
     54    RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error, 0, bodyIncludesBraces);
    5555
    5656    if (!body) {
     
    153153}
    154154
    155 UnlinkedFunctionCodeBlock* UnlinkedFunctionExecutable::codeBlockFor(VM& vm, const SourceCode& source, CodeSpecializationKind specializationKind, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
     155UnlinkedFunctionCodeBlock* UnlinkedFunctionExecutable::codeBlockFor(VM& vm, const SourceCode& source, CodeSpecializationKind specializationKind, DebuggerMode debuggerMode, ProfilerMode profilerMode, bool bodyIncludesBraces, ParserError& error)
    156156{
    157157    switch (specializationKind) {
     
    166166    }
    167167
    168     UnlinkedFunctionCodeBlock* result = generateFunctionCodeBlock(vm, this, source, specializationKind, debuggerMode, profilerMode, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, error);
     168    UnlinkedFunctionCodeBlock* result = generateFunctionCodeBlock(vm, this, source, specializationKind, debuggerMode, profilerMode, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, bodyIncludesBraces, error);
    169169   
    170170    if (error.m_type != ParserError::ErrorNone)
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r169920 r170034  
    129129    String paramString() const;
    130130
    131     UnlinkedFunctionCodeBlock* codeBlockFor(VM&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, ParserError&);
     131    UnlinkedFunctionCodeBlock* codeBlockFor(VM&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, bool bodyIncludesBraces, ParserError&);
    132132
    133133    static UnlinkedFunctionExecutable* fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r168107 r170034  
    11271127        return parseConstDeclaration(context);
    11281128    case FUNCTION:
    1129         failIfFalseIfStrict(m_statementDepth == 1, "Nested functions cannot be declared in strict mode");
     1129        failIfFalseIfStrict(m_statementDepth == 1, "Strict mode does not allow function declarations in a lexically nested statement");
    11301130        return parseFunctionDeclaration(context);
    11311131    case SEMICOLON: {
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r169920 r170034  
    399399
    400400    template <class ParsedNode>
    401     PassRefPtr<ParsedNode> parse(ParserError&);
     401    PassRefPtr<ParsedNode> parse(ParserError&, bool needReparsingAdjustment);
    402402
    403403    JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
     
    858858template <typename LexerType>
    859859template <class ParsedNode>
    860 PassRefPtr<ParsedNode> Parser<LexerType>::parse(ParserError& error)
     860PassRefPtr<ParsedNode> Parser<LexerType>::parse(ParserError& error, bool needReparsingAdjustment)
    861861{
    862862    int errLine;
    863863    String errMsg;
    864864
    865     if (ParsedNode::scopeIsFunction)
     865    if (ParsedNode::scopeIsFunction && needReparsingAdjustment)
    866866        m_lexer->setIsReparsing();
    867867
     
    938938
    939939template <class ParsedNode>
    940 PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0)
     940PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0, bool needReparsingAdjustment = false)
    941941{
    942942    SamplingRegion samplingRegion("Parsing");
     
    945945    if (source.provider()->source().is8Bit()) {
    946946        Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode);
    947         RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
     947        RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
    948948        if (positionBeforeLastNewline)
    949949            *positionBeforeLastNewline = parser.positionBeforeLastNewline();
     
    957957    }
    958958    Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode);
    959     RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
     959    RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error, needReparsingAdjustment);
    960960    if (positionBeforeLastNewline)
    961961        *positionBeforeLastNewline = parser.positionBeforeLastNewline();
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r168459 r170034  
    224224    UnlinkedFunctionCodeBlock* unlinkedCodeBlock =
    225225        executable->m_unlinkedExecutable->codeBlockFor(
    226             *vm, executable->m_source, kind, debuggerMode, profilerMode, error);
     226            *vm, executable->m_source, kind, debuggerMode, profilerMode, executable->bodyIncludesBraces(), error);
    227227    recordParse(executable->m_unlinkedExecutable->features(), executable->m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn(), endColumn());
    228228    if (!unlinkedCodeBlock) {
Note: See TracChangeset for help on using the changeset viewer.