• Sathya Gunasekaran's avatar
    [parser] Better error message when destructuring against undefined/null · bc2c785c
    Sathya Gunasekaran authored
    Previously, when destructuring against null or undefined we would
    print:
    
      d8> var { x } = null
      (d8):1: TypeError: Cannot match against 'undefined' or 'null'.
      var { x } = null
      ^
      TypeError: Cannot match against 'undefined' or 'null'.
          at (d8):1:1
    
    
    The above message uses the term "match" which isn't a common term in
    JavaScript to describe destructuring. This message also doesn't
    provide the name of the property that fails destructuring.
    
    This patch changes the error message to be:
    
      d8> var { x } = null;
      (d8):1: TypeError: Cannot destructure property `x` of 'undefined' or 'null'.
      var { x } = null;
            ^
      TypeError: Cannot destructure property `x` of 'undefined' or 'null'.
          at (d8):1:1
    
    This patch changes the message to say "destructure" instead of "match".
    
    This patch adds support for printing property names that are string
    literals. We iterate through every property and pick the first string
    literal property name if it exists. This provides at least some
    feedback to the developer.
    
    This patch also makes the pointer point to the position of the
    property name that fails destructuring.
    
    For computed and numeric property names, we print a generic error:
      d8> var { 1: x } = null
      (d8):1: TypeError: Cannot destructure against 'undefined' or 'null'.
      var { 1: x } = null
      ^
      TypeError: Cannot destructure against 'undefined' or 'null'.
          at (d8):1:1
    
    Bug: v8:6499
    Change-Id: I35b1ac749489828686f042975294b9926e2dfc53
    Reviewed-on: https://chromium-review.googlesource.com/537341Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
    Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#45965}
    bc2c785c
Name
Last commit
Last update
..
regress Loading commit data...
README.md Loading commit data...
arrow-bare-rest-param.js Loading commit data...
arrow-bare-rest-param.out Loading commit data...
arrow-formal-parameters.js Loading commit data...
arrow-formal-parameters.out Loading commit data...
arrow-invalid-rest-2.js Loading commit data...
arrow-invalid-rest-2.out Loading commit data...
arrow-invalid-rest.js Loading commit data...
arrow-invalid-rest.out Loading commit data...
arrow-missing.js Loading commit data...
arrow-missing.out Loading commit data...
arrow-param-after-rest-2.js Loading commit data...
arrow-param-after-rest-2.out Loading commit data...
arrow-param-after-rest.js Loading commit data...
arrow-param-after-rest.out Loading commit data...
arrow-strict-eval-bare-parameter.js Loading commit data...
arrow-strict-eval-bare-parameter.out Loading commit data...
arrow-two-rest-params.js Loading commit data...
arrow-two-rest-params.out Loading commit data...
asm-assignment-undeclared.js Loading commit data...
asm-assignment-undeclared.out Loading commit data...
asm-function-mismatch-def.js Loading commit data...
asm-function-mismatch-def.out Loading commit data...
asm-function-mismatch-use.js Loading commit data...
asm-function-mismatch-use.out Loading commit data...
asm-function-redefined.js Loading commit data...
asm-function-redefined.out Loading commit data...
asm-function-undefined.js Loading commit data...
asm-function-undefined.out Loading commit data...
asm-function-variable-collision.js Loading commit data...
asm-function-variable-collision.out Loading commit data...
asm-import-wrong-annotation.js Loading commit data...
asm-import-wrong-annotation.out Loading commit data...
asm-import-wrong-object.js Loading commit data...
asm-import-wrong-object.out Loading commit data...
asm-linking-bogus-heap.js Loading commit data...
asm-linking-bogus-heap.out Loading commit data...
asm-linking-bogus-stdlib.js Loading commit data...
asm-linking-bogus-stdlib.out Loading commit data...
asm-linking-missing-heap.js Loading commit data...
asm-linking-missing-heap.out Loading commit data...
asm-missing-parameter-annotation.js Loading commit data...
asm-missing-parameter-annotation.out Loading commit data...
asm-missing-return-annotation.js Loading commit data...
asm-missing-return-annotation.out Loading commit data...
asm-table-mismatch-def.js Loading commit data...
asm-table-mismatch-def.out Loading commit data...
asm-table-mismatch-use.js Loading commit data...
asm-table-mismatch-use.out Loading commit data...
asm-table-redefined.js Loading commit data...
asm-table-redefined.out Loading commit data...
asm-table-undefined.js Loading commit data...
asm-table-undefined.out Loading commit data...
asm-table-variable-collision.js Loading commit data...
asm-table-variable-collision.out Loading commit data...
async-arrow-invalid-rest-2.js Loading commit data...
async-arrow-invalid-rest-2.out Loading commit data...
async-arrow-invalid-rest.js Loading commit data...
async-arrow-invalid-rest.out Loading commit data...
async-arrow-param-after-rest.js Loading commit data...
async-arrow-param-after-rest.out Loading commit data...
call-non-constructable.js Loading commit data...
call-non-constructable.out Loading commit data...
call-primitive-constructor.js Loading commit data...
call-primitive-constructor.out Loading commit data...
call-primitive-function.js Loading commit data...
call-primitive-function.out Loading commit data...
call-undeclared-function.js Loading commit data...
call-undeclared-function.out Loading commit data...
class-constructor-accessor.js Loading commit data...
class-constructor-accessor.out Loading commit data...
class-constructor-generator.js Loading commit data...
class-constructor-generator.out Loading commit data...
class-spread-property.js Loading commit data...
class-spread-property.out Loading commit data...
console.js Loading commit data...
console.out Loading commit data...
const-decl-no-init-sloppy.out Loading commit data...
const-decl-no-init.js Loading commit data...
const-decl-no-init.out Loading commit data...
const-decl-no-init2.js Loading commit data...
const-decl-no-init2.out Loading commit data...
default-parameter-tdz-arrow.js Loading commit data...
default-parameter-tdz-arrow.out Loading commit data...
default-parameter-tdz.js Loading commit data...
default-parameter-tdz.out Loading commit data...
destructuring-decl-no-init-array.js Loading commit data...
destructuring-decl-no-init-array.out Loading commit data...
destructuring-decl-no-init-array2.js Loading commit data...
destructuring-decl-no-init-array2.out Loading commit data...
destructuring-decl-no-init-obj.js Loading commit data...
destructuring-decl-no-init-obj.out Loading commit data...
destructuring-decl-no-init-obj2.js Loading commit data...
destructuring-decl-no-init-obj2.out Loading commit data...
destructuring-modify-const.js Loading commit data...
destructuring-modify-const.out Loading commit data...
destructuring-undefined-computed-property.js Loading commit data...
destructuring-undefined-computed-property.out Loading commit data...
destructuring-undefined-number-property.js Loading commit data...
destructuring-undefined-number-property.out Loading commit data...
destructuring-undefined-string-property.js Loading commit data...
destructuring-undefined-string-property.out Loading commit data...
export-duplicate-as.js Loading commit data...
export-duplicate-as.out Loading commit data...
export-duplicate-default.js Loading commit data...
export-duplicate-default.out Loading commit data...
export-duplicate.js Loading commit data...
export-duplicate.out Loading commit data...
for-in-let-loop-initializers-strict.js Loading commit data...
for-in-let-loop-initializers-strict.out Loading commit data...
for-in-loop-initializers-destructuring.js Loading commit data...
for-in-loop-initializers-destructuring.out Loading commit data...
for-in-loop-initializers-strict.js Loading commit data...
for-in-loop-initializers-strict.out Loading commit data...
for-loop-invalid-lhs.js Loading commit data...
for-loop-invalid-lhs.out Loading commit data...
for-of-let-loop-initializers.js Loading commit data...
for-of-let-loop-initializers.out Loading commit data...
for-of-loop-initializers-sloppy.js Loading commit data...
for-of-loop-initializers-sloppy.out Loading commit data...
for-of-loop-initializers-strict.js Loading commit data...
for-of-loop-initializers-strict.out Loading commit data...
for-of-throw-in-body.js Loading commit data...
for-of-throw-in-body.out Loading commit data...
formal-parameters-bad-rest.js Loading commit data...
formal-parameters-bad-rest.out Loading commit data...
formal-parameters-strict-body.js Loading commit data...
formal-parameters-strict-body.out Loading commit data...
formal-parameters-trailing-comma.js Loading commit data...
formal-parameters-trailing-comma.out Loading commit data...
function-param-after-rest.js Loading commit data...
function-param-after-rest.out Loading commit data...
function-sent-escaped.js Loading commit data...
function-sent-escaped.out Loading commit data...
generators-throw1.js Loading commit data...
generators-throw1.out Loading commit data...
generators-throw2.js Loading commit data...
generators-throw2.out Loading commit data...
get-iterator1.js Loading commit data...
get-iterator1.out Loading commit data...
import-as-eval.js Loading commit data...
import-as-eval.out Loading commit data...
import-as-redeclaration.js Loading commit data...
import-as-redeclaration.out Loading commit data...
import-as-reserved-word.js Loading commit data...
import-as-reserved-word.out Loading commit data...
import-eval.js Loading commit data...
import-eval.out Loading commit data...
import-redeclaration.js Loading commit data...
import-redeclaration.out Loading commit data...
import-reserved-word.js Loading commit data...
import-reserved-word.out Loading commit data...
instanceof-noncallable.js Loading commit data...
instanceof-noncallable.out Loading commit data...
instanceof-nonobject.js Loading commit data...
instanceof-nonobject.out Loading commit data...
invalid-spread-2.js Loading commit data...
invalid-spread-2.out Loading commit data...
invalid-spread.js Loading commit data...
invalid-spread.out Loading commit data...
isvar.js Loading commit data...
isvar.out Loading commit data...
let-asi-await-nonasync.js Loading commit data...
let-asi-await-nonasync.out Loading commit data...
let-asi-yield-nongenerator.js Loading commit data...
let-asi-yield-nongenerator.out Loading commit data...
let-lexical-declaration-destructuring-brace-in-single-statement.js Loading commit data...
let-lexical-declaration-destructuring-brace-in-single-statement.out Loading commit data...
let-lexical-declaration-destructuring-in-single-statement.js Loading commit data...
let-lexical-declaration-destructuring-in-single-statement.out Loading commit data...
let-lexical-declaration-in-single-statement.js Loading commit data...
let-lexical-declaration-in-single-statement.out Loading commit data...
let-lexical-name-in-array-prohibited.js Loading commit data...
let-lexical-name-in-array-prohibited.out Loading commit data...
let-lexical-name-in-object-prohibited.js Loading commit data...
let-lexical-name-in-object-prohibited.out Loading commit data...
let-lexical-name-prohibited.js Loading commit data...
let-lexical-name-prohibited.out Loading commit data...
message.gyp Loading commit data...
message.isolate Loading commit data...
message.status Loading commit data...
modules-cycle1.js Loading commit data...
modules-cycle1.out Loading commit data...
modules-cycle2.js Loading commit data...
modules-cycle2.out Loading commit data...
modules-cycle3.js Loading commit data...
modules-cycle3.out Loading commit data...
modules-cycle4.js Loading commit data...
modules-cycle4.out Loading commit data...
modules-cycle5.js Loading commit data...
modules-cycle5.out Loading commit data...
modules-cycle6.js Loading commit data...
modules-cycle6.out Loading commit data...
modules-duplicate-export1.js Loading commit data...
modules-duplicate-export1.out Loading commit data...
modules-duplicate-export2.js Loading commit data...
modules-duplicate-export2.out Loading commit data...
modules-duplicate-export3.js Loading commit data...
modules-duplicate-export3.out Loading commit data...
modules-duplicate-export4.js Loading commit data...
modules-duplicate-export4.out Loading commit data...
modules-import-redeclare1.js Loading commit data...
modules-import-redeclare1.out Loading commit data...
modules-import-redeclare2.js Loading commit data...
modules-import-redeclare2.out Loading commit data...
modules-import-redeclare3.js Loading commit data...
modules-import-redeclare3.out Loading commit data...
modules-import1.js Loading commit data...
modules-import1.out Loading commit data...
modules-import2.js Loading commit data...
modules-import2.out Loading commit data...
modules-import3.js Loading commit data...
modules-import3.out Loading commit data...
modules-import4.js Loading commit data...
modules-import4.out Loading commit data...
modules-import5.js Loading commit data...
modules-import5.out Loading commit data...
modules-import6.js Loading commit data...
modules-import6.out Loading commit data...
modules-skip-cycle2.js Loading commit data...
modules-skip-cycle3.js Loading commit data...
modules-skip-cycle5.js Loading commit data...
modules-skip-cycle6.js Loading commit data...
modules-star-conflict1.js Loading commit data...
modules-star-conflict1.out Loading commit data...
modules-star-conflict2.js Loading commit data...
modules-star-conflict2.out Loading commit data...
modules-star-default.js Loading commit data...
modules-star-default.out Loading commit data...
modules-undefined-export1.js Loading commit data...
modules-undefined-export1.out Loading commit data...
modules-undefined-export2.js Loading commit data...
modules-undefined-export2.out Loading commit data...
new-target-assignment.js Loading commit data...
new-target-assignment.out Loading commit data...
new-target-escaped.js Loading commit data...
new-target-escaped.out Loading commit data...
new-target-for-loop.js Loading commit data...
new-target-for-loop.out Loading commit data...
new-target-postfix-op.js Loading commit data...
new-target-postfix-op.out Loading commit data...
new-target-prefix-op.js Loading commit data...
new-target-prefix-op.out Loading commit data...
nf-yield-in-generator.js Loading commit data...
nf-yield-in-generator.out Loading commit data...
nf-yield-strict-in-generator.js Loading commit data...
nf-yield-strict-in-generator.out Loading commit data...
nf-yield-strict.js Loading commit data...
nf-yield-strict.out Loading commit data...
nfe-yield-generator.js Loading commit data...
nfe-yield-generator.out Loading commit data...
nfe-yield-strict.js Loading commit data...
nfe-yield-strict.out Loading commit data...
non-alphanum.js Loading commit data...
non-alphanum.out Loading commit data...
non-use-strict-hex-escape.js Loading commit data...
non-use-strict-hex-escape.out Loading commit data...
non-use-strict-octal-escape.js Loading commit data...
non-use-strict-octal-escape.out Loading commit data...
non-use-strict-uhex-escape.js Loading commit data...
non-use-strict-uhex-escape.out Loading commit data...
nonstrict-arguments.js Loading commit data...
nonstrict-arguments.out Loading commit data...
nonstrict-eval.js Loading commit data...
nonstrict-eval.out Loading commit data...
nonstrict-with.js Loading commit data...
nonstrict-with.out Loading commit data...
overwritten-builtins.js Loading commit data...
overwritten-builtins.out Loading commit data...
paren_in_arg_string.js Loading commit data...
paren_in_arg_string.out Loading commit data...
redeclaration1.js Loading commit data...
redeclaration1.out Loading commit data...
redeclaration2.js Loading commit data...
redeclaration2.out Loading commit data...
redeclaration3.js Loading commit data...
redeclaration3.out Loading commit data...
replacement-marker-as-argument.js Loading commit data...
replacement-marker-as-argument.out Loading commit data...
rest-param-class-setter-strict.js Loading commit data...
rest-param-class-setter-strict.out Loading commit data...
rest-param-object-setter-sloppy.js Loading commit data...
rest-param-object-setter-sloppy.out Loading commit data...
rest-param-object-setter-strict.js Loading commit data...
rest-param-object-setter-strict.out Loading commit data...
simple-throw.js Loading commit data...
simple-throw.out Loading commit data...
strict-formal-parameters.js Loading commit data...
strict-formal-parameters.out Loading commit data...
strict-octal-indirect-regexp.js Loading commit data...
strict-octal-indirect-regexp.out Loading commit data...
strict-octal-number.js Loading commit data...
strict-octal-number.out Loading commit data...
strict-octal-regexp.js Loading commit data...
strict-octal-regexp.out Loading commit data...
strict-octal-string.js Loading commit data...
strict-octal-string.out Loading commit data...
strict-octal-use-strict-after.js Loading commit data...
strict-octal-use-strict-after.out Loading commit data...
strict-octal-use-strict-before.js Loading commit data...
strict-octal-use-strict-before.out Loading commit data...
strict-with.js Loading commit data...
strict-with.out Loading commit data...
super-constructor-extra-statement.js Loading commit data...
super-constructor-extra-statement.out Loading commit data...
super-constructor.js Loading commit data...
super-constructor.out Loading commit data...
super-in-function.js Loading commit data...
super-in-function.out Loading commit data...
testcfg.py Loading commit data...
tonumber-symbol.js Loading commit data...
tonumber-symbol.out Loading commit data...
try-catch-finally-no-message.js Loading commit data...
try-catch-finally-no-message.out Loading commit data...
try-catch-finally-return-in-finally.js Loading commit data...
try-catch-finally-return-in-finally.out Loading commit data...
try-catch-finally-throw-in-catch-and-finally.js Loading commit data...
try-catch-finally-throw-in-catch-and-finally.out Loading commit data...
try-catch-finally-throw-in-catch.js Loading commit data...
try-catch-finally-throw-in-catch.out Loading commit data...
try-catch-finally-throw-in-finally.js Loading commit data...
try-catch-finally-throw-in-finally.out Loading commit data...
try-catch-lexical-conflict.js Loading commit data...
try-catch-lexical-conflict.out Loading commit data...
try-catch-variable-conflict.js Loading commit data...
try-catch-variable-conflict.out Loading commit data...
try-finally-return-in-finally.js Loading commit data...
try-finally-return-in-finally.out Loading commit data...
try-finally-throw-in-finally.js Loading commit data...
try-finally-throw-in-finally.out Loading commit data...
try-finally-throw-in-try-and-finally.js Loading commit data...
try-finally-throw-in-try-and-finally.out Loading commit data...
try-finally-throw-in-try.js Loading commit data...
try-finally-throw-in-try.out Loading commit data...
unicode-escape-invalid-2.js Loading commit data...
unicode-escape-invalid-2.out Loading commit data...
unicode-escape-invalid.js Loading commit data...
unicode-escape-invalid.out Loading commit data...
unicode-escape-undefined.js Loading commit data...
unicode-escape-undefined.out Loading commit data...
unterminated-arg-list.js Loading commit data...
unterminated-arg-list.out Loading commit data...
wasm-function-name.js Loading commit data...
wasm-function-name.out Loading commit data...
wasm-module-and-function-name.js Loading commit data...
wasm-module-and-function-name.out Loading commit data...
wasm-module-name.js Loading commit data...
wasm-module-name.out Loading commit data...
wasm-no-name.js Loading commit data...
wasm-no-name.out Loading commit data...
wasm-trap.js Loading commit data...
wasm-trap.out Loading commit data...
yield-in-arrow-param.js Loading commit data...
yield-in-arrow-param.out Loading commit data...
yield-in-generator-param.js Loading commit data...
yield-in-generator-param.out Loading commit data...