v8/test/cctest/interpreter
Sathya Gunasekaran bc2c785c20 [parser] Better error message when destructuring against undefined/null
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/537341
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45965}
2017-06-15 21:52:58 +00:00
..
bytecode_expectations [parser] Better error message when destructuring against undefined/null 2017-06-15 21:52:58 +00:00
bytecode-expectations-printer.cc [inspector] cache stack frame for call sites 2017-04-12 18:33:20 +00:00
bytecode-expectations-printer.h [interpreter] Add some bytecode tests for modules. 2016-10-04 18:42:36 +00:00
generate-bytecode-expectations.cc [cleanup] Remove return after UNREACHABLE 2017-05-22 13:10:01 +00:00
interpreter-tester.cc Rename TypeFeedbackVector to FeedbackVector. 2017-02-07 14:46:36 +00:00
interpreter-tester.h Link type feedback vectors to the shared function info. 2017-02-08 08:33:33 +00:00
source-position-matcher.cc [inspector] cache stack frame for call sites 2017-04-12 18:33:20 +00:00
source-position-matcher.h Use source position table for unoptimized code. 2016-06-28 05:52:52 +00:00
test-bytecode-generator.cc [generators] Improve yield* desugaring to save unnecessary try/catch and try/finally 2017-05-22 16:08:41 +00:00
test-interpreter-intrinsics.cc [interpreter] Split function into Receiver() and Parameter(i). 2017-03-30 09:40:08 +00:00
test-interpreter.cc [TurboFan] Add typing for the EmptyString and use this for JSToPrimitiveToString 2017-06-08 09:51:26 +00:00
test-source-positions.cc [Interpreter] Move dead code elimination to BytecodeArrayWriter. 2017-04-11 12:39:14 +00:00