Changeset 207326 in webkit


Ignore:
Timestamp:
Oct 13, 2016 11:31:40 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Exception message for expressions with multiple bracket accesses is inconsistent / incorrect
https://bugs.webkit.org/show_bug.cgi?id=163426

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-10-13
Reviewed by Geoffrey Garen.

JSTests:

  • ChakraCore/test/Error/CallNonFunction_3.baseline-jsc:
  • ChakraCore/test/Object/null.baseline-jsc:
  • stress/exception-in-to-property-key-should-be-handled-early.js:

Better exception messages.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime-expected.txt:
  • web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id-expected.txt:
  • web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit-expected.txt:
  • web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime-expected.txt:
  • web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track-expected.txt:

Better expection messages.

Source/JavaScriptCore:

  • bytecompiler/NodesCodegen.cpp:

(JSC::BracketAccessorNode::emitBytecode):
It matters where emitExpressionInfo is called since it gathers
info about where we are in the instruction stream. We need to
emit it before the bytecode that we want to associate the data
with. In this case, before the getById / getByVal.

LayoutTests:

  • js/exception-expression-offset-expected.txt:
  • js/script-tests/exception-expression-offset.js:

(testException):
Correct existing tests and add new tests for multiple and intermixed
dot / bracket accesses.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChakraCore/test/Error/CallNonFunction_3.baseline-jsc

    r205387 r207326  
    1313TypeError (undefined): 1 is not a constructor (evaluating 'new obj[1]()')
    1414TypeError (undefined): null is not an object (evaluating 'n[1]')
    15 TypeError (undefined): null is not an object (evaluating 'n')
     15TypeError (undefined): null is not an object (evaluating 'new n[1]')
    1616TypeError (undefined): null is not an object (evaluating 'n.prop')
    1717TypeError (undefined): null is not an object (evaluating 'new n.prop')
  • trunk/JSTests/ChakraCore/test/Object/null.baseline-jsc

    r205387 r207326  
    221 null is not an object (evaluating 'x.y = 5')
    332 null is not an object (evaluating 'delete x.y')
    4 3 null is not an object (evaluating 'x')
     43 null is not an object (evaluating 'x[6]')
    554 null is not an object (evaluating 'x[6] = 7')
    665 null is not an object (evaluating 'delete x[6]')
     
    887 undefined is not an object (evaluating 'x.y = 5')
    998 undefined is not an object (evaluating 'delete x.y')
    10 9 undefined is not an object (evaluating 'x')
     109 undefined is not an object (evaluating 'x[6]')
    111110 undefined is not an object (evaluating 'x[6] = 7')
    121211 undefined is not an object (evaluating 'delete x[6]')
     
    141413 null is not an object (evaluating 'a[0].y = 5')
    151514 null is not an object (evaluating 'delete a[0].y')
    16 15 null is not an object (evaluating 'a[0]')
     1615 null is not an object (evaluating 'a[0][6]')
    171716 null is not an object (evaluating 'a[0][6] = 7')
    181817 null is not an object (evaluating 'delete a[0][6]')
     
    202019 undefined is not an object (evaluating 'a[0].y = 5')
    212120 undefined is not an object (evaluating 'delete a[0].y')
    22 21 undefined is not an object (evaluating 'a[0]')
     2221 undefined is not an object (evaluating 'a[0][6]')
    232322 undefined is not an object (evaluating 'a[0][6] = 7')
    242423 undefined is not an object (evaluating 'delete a[0][6]')
     
    262625 null is not an object (evaluating 'o.z.y = 5')
    272726 null is not an object (evaluating 'delete o.z.y')
    28 27 null is not an object (evaluating 'o.z')
     2827 null is not an object (evaluating 'o.z[6]')
    292928 null is not an object (evaluating 'o.z[6] = 7')
    303029 null is not an object (evaluating 'delete o.z[6]')
     
    323231 undefined is not an object (evaluating 'o.z.y = 5')
    333332 undefined is not an object (evaluating 'delete o.z.y')
    34 33 undefined is not an object (evaluating 'o.z')
     3433 undefined is not an object (evaluating 'o.z[6]')
    353534 undefined is not an object (evaluating 'o.z[6] = 7')
    363635 undefined is not an object (evaluating 'delete o.z[6]')
  • trunk/JSTests/ChangeLog

    r207322 r207326  
     12016-10-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Exception message for expressions with multiple bracket accesses is inconsistent / incorrect
     4        https://bugs.webkit.org/show_bug.cgi?id=163426
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * ChakraCore/test/Error/CallNonFunction_3.baseline-jsc:
     9        * ChakraCore/test/Object/null.baseline-jsc:
     10        * stress/exception-in-to-property-key-should-be-handled-early.js:
     11        Better exception messages.
     12
    1132016-10-13  Mark Lam  <mark.lam@apple.com>
    214
  • trunk/JSTests/stress/exception-in-to-property-key-should-be-handled-early.js

    r182057 r207326  
    134134        throw new Error(called);
    135135    toStringCalled = false;
    136     shouldThrow(function () { test(null, 20, propertyKey); }, "TypeError: null is not an object (near '...for (var i = 0; i < length; ++i)...')");
     136    shouldThrow(function () { test(null, 20, propertyKey); }, "TypeError: null is not an object (evaluating 'array[property]')");
    137137    if (toStringCalled)
    138138        throw new Error("toString is called.");
  • trunk/LayoutTests/ChangeLog

    r207321 r207326  
     12016-10-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Exception message for expressions with multiple bracket accesses is inconsistent / incorrect
     4        https://bugs.webkit.org/show_bug.cgi?id=163426
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/exception-expression-offset-expected.txt:
     9        * js/script-tests/exception-expression-offset.js:
     10        (testException):
     11        Correct existing tests and add new tests for multiple and intermixed
     12        dot / bracket accesses.
     13
    1142016-10-13  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r207321 r207326  
     12016-10-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Exception message for expressions with multiple bracket accesses is inconsistent / incorrect
     4        https://bugs.webkit.org/show_bug.cgi?id=163426
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime-expected.txt:
     9        * web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id-expected.txt:
     10        * web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit-expected.txt:
     11        * web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime-expected.txt:
     12        * web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track-expected.txt:
     13        Better expection messages.
     14
    1152016-10-13  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/endTime-expected.txt

    r205750 r207326  
    11
    22PASS TextTrackCue.endTime, script-created cue
    3 FAIL TextTrackCue.endTime, parsed cue null is not an object (evaluating 'assert_equals')
     3FAIL TextTrackCue.endTime, parsed cue null is not an object (evaluating 'c[0]')
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/id-expected.txt

    r205750 r207326  
    11
    22PASS TextTrackCue.id, script-created cue
    3 FAIL TextTrackCue.id, parsed cue null is not an object (evaluating 'assert_equals')
     3FAIL TextTrackCue.id, parsed cue null is not an object (evaluating 'c[0]')
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/pauseOnExit-expected.txt

    r205750 r207326  
    11
    22PASS TextTrackCue.pauseOnExit, script-created cue
    3 FAIL TextTrackCue.pauseOnExit, parsed cue null is not an object (evaluating 't.track.cues')
     3FAIL TextTrackCue.pauseOnExit, parsed cue null is not an object (evaluating 't.track.cues[0]')
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/startTime-expected.txt

    r205750 r207326  
    11
    22PASS TextTrackCue.startTime, script-created cue
    3 FAIL TextTrackCue.startTime, parsed cue null is not an object (evaluating 'assert_equals')
     3FAIL TextTrackCue.startTime, parsed cue null is not an object (evaluating 'c[0]')
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/track-expected.txt

    r205750 r207326  
    11
    22PASS TextTrackCue.track, script-created cue
    3 FAIL TextTrackCue.track, parsed cue null is not an object (evaluating 't.track.cues')
     3FAIL TextTrackCue.track, parsed cue null is not an object (evaluating 't.track.cues[0]')
    44
  • trunk/LayoutTests/js/exception-expression-offset-expected.txt

    r152871 r207326  
    66
    77Testing 'undefined.a++'
    8 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.a')" should be true. Was false.
     8PASS ex.message is "undefined is not an object (evaluating 'undefined.a')"
    99
    1010Testing '++undefined.a'
    11 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.a')" should be true. Was false.
     11PASS ex.message is "undefined is not an object (evaluating 'undefined.a')"
    1212
    1313Testing 'undefined[0]++'
    14 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0]')" should be true. Was false.
     14PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
    1515
    1616Testing '++undefined[1]'
    17 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[1]')" should be true. Was false.
     17PASS ex.message is "undefined is not an object (evaluating 'undefined[1]')"
    1818
    1919Testing 'undefined.b'
    20 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.b')" should be true. Was false.
     20PASS ex.message is "undefined is not an object (evaluating 'undefined.b')"
    2121
    2222Testing 'undefined[0]'
    23 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0]')" should be true. Was false.
     23PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
    2424
    2525Testing 'undefined.b += 1'
    26 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.b')" should be true. Was false.
     26PASS ex.message is "undefined is not an object (evaluating 'undefined.b')"
    2727
    2828Testing 'undefined[0] += 1'
    29 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0]')" should be true. Was false.
     29PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
    3030
    3131Testing 'undefined()'
    32 FAIL ex.message == "'undefined' is not a function (evaluating 'undefined()')" should be true. Was false.
     32PASS ex.message is "undefined is not a function. (In 'undefined()', 'undefined' is undefined)"
    3333
    3434Testing 'new undefined()'
    35 FAIL ex.message == "'undefined' is not a constructor (evaluating 'new undefined()')" should be true. Was false.
     35PASS ex.message is "undefined is not a constructor (evaluating 'new undefined()')"
    3636
    3737Testing '({}).b()'
    38 FAIL ex.message == "'undefined' is not a function (evaluating '({}).b()')" should be true. Was false.
     38PASS ex.message is "({}).b is not a function. (In '({}).b()', '({}).b' is undefined)"
    3939
    4040Testing 'new {}.b()'
    41 FAIL ex.message == "'undefined' is not a constructor (evaluating 'new {}.b()')" should be true. Was false.
     41PASS ex.message is "undefined is not a constructor (evaluating 'new {}.b()')"
    4242
    4343Testing '1()'
    44 FAIL ex.message == "'1' is not a function (evaluating '1()')" should be true. Was false.
     44PASS ex.message is "1 is not a function. (In '1()', '1' is 1)"
    4545
    4646Testing 'new 1()'
    47 FAIL ex.message == "'1' is not a constructor (evaluating 'new 1()')" should be true. Was false.
     47PASS ex.message is "1 is not a constructor (evaluating 'new 1()')"
    4848
    4949Testing 'throw { message : 'thrown object' }'
    50 PASS ex.message == "thrown object" is true
     50PASS ex.message is "thrown object"
    5151
    5252Testing '1 in undefined'
    53 FAIL ex.message == "'undefined' is not a valid argument for 'in' (evaluating '1 in undefined')" should be true. Was false.
     53PASS ex.message is "undefined is not an Object. (evaluating '1 in undefined')"
    5454
    5555Testing '1 instanceof undefined'
    56 FAIL ex.message == "'undefined' is not a valid argument for 'instanceof' (evaluating '1 instanceof undefined')" should be true. Was false.
     56PASS ex.message is "Right hand side of instanceof is not an object"
    5757
    5858Testing 'for (undefined.b in [1]) {}'
    59 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.b')" should be true. Was false.
     59PASS ex.message is "undefined is not an object (evaluating 'undefined.b')"
    6060
    6161Testing 'for (undefined[0] in [1]) {}'
    62 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0]')" should be true. Was false.
     62PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
    6363
    6464Testing 'undefined.a = 5'
    65 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.a = 5')" should be true. Was false.
     65PASS ex.message is "undefined is not an object (evaluating 'undefined.a = 5')"
    6666
    6767Testing 'undefined[0] = 5'
    68 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0] = 5')" should be true. Was false.
     68PASS ex.message is "undefined is not an object (evaluating 'undefined[0] = 5')"
    6969
    7070Testing '({b:undefined}).b.a = 5'
    71 FAIL ex.message == "'undefined' is not an object (evaluating '({b:undefined}).b.a = 5')" should be true. Was false.
     71PASS ex.message is "undefined is not an object (evaluating '({b:undefined}).b.a = 5')"
    7272
    7373Testing '({b:undefined}).b[0] = 5'
    74 FAIL ex.message == "'undefined' is not an object (evaluating '({b:undefined}).b[0] = 5')" should be true. Was false.
     74PASS ex.message is "undefined is not an object (evaluating '({b:undefined}).b[0] = 5')"
    7575
    7676Testing 'undefined.a += 5'
    77 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined.a')" should be true. Was false.
     77PASS ex.message is "undefined is not an object (evaluating 'undefined.a')"
    7878
    7979Testing 'undefined[0] += 5'
    80 FAIL ex.message == "'undefined' is not an object (evaluating 'undefined[0]')" should be true. Was false.
     80PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
    8181
    8282Testing '({b:undefined}).b.a += 5'
    83 FAIL ex.message == "'undefined' is not an object (evaluating '({b:undefined}).b.a')" should be true. Was false.
     83PASS ex.message is "undefined is not an object (evaluating '({b:undefined}).b.a')"
    8484
    8585Testing '({b:undefined}).b[0] += 5'
    86 FAIL ex.message == "'undefined' is not an object (evaluating '({b:undefined}).b[0]')" should be true. Was false.
     86PASS ex.message is "undefined is not an object (evaluating '({b:undefined}).b[0]')"
     87
     88Testing '[].a.b.x'
     89PASS ex.message is "undefined is not an object (evaluating '[].a.b')"
     90
     91Testing '[]['a']['b'].x'
     92PASS ex.message is "undefined is not an object (evaluating '[]['a']['b']')"
     93
     94Testing '[].a['b'].x'
     95PASS ex.message is "undefined is not an object (evaluating '[].a['b']')"
     96
     97Testing '[]['a'].b.x'
     98PASS ex.message is "undefined is not an object (evaluating '[]['a'].b')"
     99
     100Testing 'func(undefined.x)'
     101PASS ex.message is "undefined is not an object (evaluating 'undefined.x')"
     102
     103Testing 'func(null.x)'
     104PASS ex.message is "null is not an object (evaluating 'null.x')"
     105
     106Testing 'func(undefined[0])'
     107PASS ex.message is "undefined is not an object (evaluating 'undefined[0]')"
     108
     109Testing 'func(null[0])'
     110PASS ex.message is "null is not an object (evaluating 'null[0]')"
    87111PASS successfullyParsed is true
    88112
  • trunk/LayoutTests/js/script-tests/exception-expression-offset.js

    r98407 r207326  
    1010        ex = e;
    1111        // begin/caret/end are not presently exposed in a web facing interface, so cannot be directly checked.
    12         shouldBeTrue('ex.message == "' + message +'"');
     12        shouldBeEqualToString("ex.message", message);
    1313    }
    1414}
    1515
    16 testException("undefined.a++", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.a')");
    17 testException("++undefined.a", 2, 11, 13, "'undefined' is not an object (evaluating 'undefined.a')");
    18 testException("undefined[0]++", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
    19 testException("++undefined[1]", 2, 11, 14, "'undefined' is not an object (evaluating 'undefined[1]')");
    20 testException("undefined.b", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.b')");
    21 testException("undefined[0]", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
    22 testException("undefined.b += 1", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.b')");
    23 testException("undefined[0] += 1", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
    24 testException("undefined()", 0, 9, 11, "'undefined' is not a function (evaluating 'undefined()')");
    25 testException("new undefined()", 0, 13, 15, "'undefined' is not a constructor (evaluating 'new undefined()')");
    26 testException("({}).b()", 0, 6, 8, "'undefined' is not a function (evaluating '({}).b()')");
    27 testException("new {}.b()", 0, 8, 10, "'undefined' is not a constructor (evaluating 'new {}.b()')");
    28 testException("1()", 0, 1, 3, "'1' is not a function (evaluating '1()')");
    29 testException("new 1()", 0, 5, 7, "'1' is not a constructor (evaluating 'new 1()')");
     16function func() {}
     17
     18testException("undefined.a++", 0, 9, 11, "undefined is not an object (evaluating 'undefined.a')");
     19testException("++undefined.a", 2, 11, 13, "undefined is not an object (evaluating 'undefined.a')");
     20testException("undefined[0]++", 0, 9, 12, "undefined is not an object (evaluating 'undefined[0]')");
     21testException("++undefined[1]", 2, 11, 14, "undefined is not an object (evaluating 'undefined[1]')");
     22testException("undefined.b", 0, 9, 11, "undefined is not an object (evaluating 'undefined.b')");
     23testException("undefined[0]", 0, 9, 12, "undefined is not an object (evaluating 'undefined[0]')");
     24testException("undefined.b += 1", 0, 9, 11, "undefined is not an object (evaluating 'undefined.b')");
     25testException("undefined[0] += 1", 0, 9, 12, "undefined is not an object (evaluating 'undefined[0]')");
     26testException("undefined()", 0, 9, 11, "undefined is not a function. (In 'undefined()', 'undefined' is undefined)");
     27testException("new undefined()", 0, 13, 15, "undefined is not a constructor (evaluating 'new undefined()')");
     28testException("({}).b()", 0, 6, 8, "({}).b is not a function. (In '({}).b()', '({}).b' is undefined)");
     29testException("new {}.b()", 0, 8, 10, "undefined is not a constructor (evaluating 'new {}.b()')");
     30testException("1()", 0, 1, 3, "1 is not a function. (In '1()', '1' is 1)");
     31testException("new 1()", 0, 5, 7, "1 is not a constructor (evaluating 'new 1()')");
    3032testException("throw { message : 'thrown object' }", 0, undefined, 35, "thrown object");
    31 testException("1 in undefined", 0, 5, 14, "'undefined' is not a valid argument for 'in' (evaluating '1 in undefined')");
    32 testException("1 instanceof undefined", 0, 13, 22, "'undefined' is not a valid argument for 'instanceof' (evaluating '1 instanceof undefined')");
    33 testException("for (undefined.b in [1]) {}", 5, 14, 16, "'undefined' is not an object (evaluating 'undefined.b')");
    34 testException("for (undefined[0] in [1]) {}", 5, 14, 17, "'undefined' is not an object (evaluating 'undefined[0]')");
    35 testException("undefined.a = 5", 0, 9, 15, "'undefined' is not an object (evaluating 'undefined.a = 5')");
    36 testException("undefined[0] = 5", 0, 9, 16, "'undefined' is not an object (evaluating 'undefined[0] = 5')");
    37 testException("({b:undefined}).b.a = 5", 0, 17, 23, "'undefined' is not an object (evaluating '({b:undefined}).b.a = 5')");
    38 testException("({b:undefined}).b[0] = 5", 0, 17, 24, "'undefined' is not an object (evaluating '({b:undefined}).b[0] = 5')");
    39 testException("undefined.a += 5", 0, 9, 11, "'undefined' is not an object (evaluating 'undefined.a')");
    40 testException("undefined[0] += 5", 0, 9, 12, "'undefined' is not an object (evaluating 'undefined[0]')");
    41 testException("({b:undefined}).b.a += 5", 0, 17, 19, "'undefined' is not an object (evaluating '({b:undefined}).b.a')");
    42 testException("({b:undefined}).b[0] += 5", 0, 17, 20, "'undefined' is not an object (evaluating '({b:undefined}).b[0]')");
     33testException("1 in undefined", 0, 5, 14, "undefined is not an Object. (evaluating '1 in undefined')");
     34testException("1 instanceof undefined", 0, 13, 22, "Right hand side of instanceof is not an object");
     35testException("for (undefined.b in [1]) {}", 5, 14, 16, "undefined is not an object (evaluating 'undefined.b')");
     36testException("for (undefined[0] in [1]) {}", 5, 14, 17, "undefined is not an object (evaluating 'undefined[0]')");
     37testException("undefined.a = 5", 0, 9, 15, "undefined is not an object (evaluating 'undefined.a = 5')");
     38testException("undefined[0] = 5", 0, 9, 16, "undefined is not an object (evaluating 'undefined[0] = 5')");
     39testException("({b:undefined}).b.a = 5", 0, 17, 23, "undefined is not an object (evaluating '({b:undefined}).b.a = 5')");
     40testException("({b:undefined}).b[0] = 5", 0, 17, 24, "undefined is not an object (evaluating '({b:undefined}).b[0] = 5')");
     41testException("undefined.a += 5", 0, 9, 11, "undefined is not an object (evaluating 'undefined.a')");
     42testException("undefined[0] += 5", 0, 9, 12, "undefined is not an object (evaluating 'undefined[0]')");
     43testException("({b:undefined}).b.a += 5", 0, 17, 19, "undefined is not an object (evaluating '({b:undefined}).b.a')");
     44testException("({b:undefined}).b[0] += 5", 0, 17, 20, "undefined is not an object (evaluating '({b:undefined}).b[0]')");
     45
     46testException("[].a.b.x", 0, 4, 5, "undefined is not an object (evaluating '[].a.b')");
     47testException("[]['a']['b'].x", 0, 7, 11, "undefined is not an object (evaluating '[]['a']['b']')");
     48testException("[].a['b'].x", 0, 4, 8, "undefined is not an object (evaluating '[].a['b']')");
     49testException("[]['a'].b.x", 0, 7, 8, "undefined is not an object (evaluating '[]['a'].b')");
     50
     51testException("func(undefined.x)", 5, 14, 15, "undefined is not an object (evaluating 'undefined.x')");
     52testException("func(null.x)", 5, 9, 10, "null is not an object (evaluating 'null.x')");
     53testException("func(undefined[0])", 5, 14, 16, "undefined is not an object (evaluating 'undefined[0]')");
     54testException("func(null[0])", 5, 9, 11, "null is not an object (evaluating 'null[0]')");
  • trunk/Source/JavaScriptCore/ChangeLog

    r207322 r207326  
     12016-10-13  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Exception message for expressions with multiple bracket accesses is inconsistent / incorrect
     4        https://bugs.webkit.org/show_bug.cgi?id=163426
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * bytecompiler/NodesCodegen.cpp:
     9        (JSC::BracketAccessorNode::emitBytecode):
     10        It matters where emitExpressionInfo is called since it gathers
     11        info about where we are in the instruction stream. We need to
     12        emit it before the bytecode that we want to associate the data
     13        with. In this case, before the getById / getByVal.
     14
    1152016-10-13  Mark Lam  <mark.lam@apple.com>
    216
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r207228 r207326  
    634634        RefPtr<RegisterID> thisValue = generator.ensureThis();
    635635        RefPtr<RegisterID> superBase = emitSuperBaseForCallee(generator);
     636
    636637        if (isNonIndexStringElement(*m_subscript)) {
    637638            const Identifier& id = static_cast<StringNode*>(m_subscript)->value();
     639            generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    638640            generator.emitGetById(finalDest.get(), superBase.get(), thisValue.get(), id);
    639641        } else  {
    640642            RefPtr<RegisterID> subscript = generator.emitNode(m_subscript);
     643            generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    641644            generator.emitGetByVal(finalDest.get(), superBase.get(), thisValue.get(), subscript.get());
    642645        }
    643646
    644         generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    645647        generator.emitProfileType(finalDest.get(), divotStart(), divotEnd());
    646648        return finalDest.get();
     
    652654    if (isNonIndexStringElement(*m_subscript)) {
    653655        RefPtr<RegisterID> base = generator.emitNode(m_base);
     656        generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    654657        ret = generator.emitGetById(finalDest.get(), base.get(), static_cast<StringNode*>(m_subscript)->value());
    655658    } else {
    656659        RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_subscriptHasAssignments, m_subscript->isPure(generator));
    657660        RegisterID* property = generator.emitNode(m_subscript);
     661        generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    658662        ret = generator.emitGetByVal(finalDest.get(), base.get(), property);
    659663    }
    660 
    661     generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
    662664
    663665    generator.emitProfileType(finalDest.get(), divotStart(), divotEnd());
Note: See TracChangeset for help on using the changeset viewer.