ladybird/Userland/Libraries/LibJS/Tests
Linus Groh 3709d11212 LibJS: Parse secondary expressions with the original forbidden token set
Instead of passing the continuously merged initial forbidden token set
(with the new additional forbidden tokens from each parsed secondary
expression) to the next call of parse_secondary_expression(), keep a
copy of the original set and use it as the base for parsing the next
secondary expression.

This bug prevented us from properly parsing the following expression:

```js
0 ?? 0 ? 0 : 0 || 0
```

...due to LogicalExpression with LogicalOp::NullishCoalescing returning
both DoubleAmpersand and DoublePipe in its forbidden token set.

The following correct AST is now generated:

Program
  (Children)
    ExpressionStatement
      ConditionalExpression
        (Test)
          LogicalExpression
            NumericLiteral 0
            ??
            NumericLiteral 0
        (Consequent)
          NumericLiteral 0
        (Alternate)
          LogicalExpression
            NumericLiteral 0
            ||
            NumericLiteral 0

An alternate solution I explored was only merging the original forbidden
token set with the one of the last parsed secondary expression which is
then passed to match_secondary_expression(); however that led to an
incorrect AST (note the alternate expression):

Program
  (Children)
    ExpressionStatement
      LogicalExpression
        ConditionalExpression
          (Test)
            LogicalExpression
              NumericLiteral 0
              ??
              NumericLiteral 0
          (Consequent)
            NumericLiteral 0
          (Alternate)
            NumericLiteral 0
        ||
        NumericLiteral 0

Truth be told, I don't know enough about the inner workings of the
parser to fully explain the difference. AFAICT this patch has no
unintended side effects in its current form though.

Fixes #18087.
2023-04-02 06:45:37 +02:00
..
builtins LibJS: Make yy{/,-}mm{/,-}dd hh:mm test timezone independent 2023-03-23 13:33:03 -04:00
classes LibJS: Make sure private identifier is valid in optional chain 2022-11-17 16:05:20 +00:00
functions
iterators
loops LibJS: Fix that constant declaration in for loop was mutable in body 2022-11-30 08:05:37 +01:00
modules LibJS: Add using declaration support, RAII like operation in js 2023-01-23 09:56:50 +00:00
operators LibJS: Use ToPropertyKey AO for computed member expression value 2022-12-10 01:08:34 +00:00
syntax LibJS: Parse secondary expressions with the original forbidden token set 2023-04-02 06:45:37 +02:00
add-values-to-primitive.js
arguments-callee.js
arguments-object.js
automatic-semicolon-insertion.js
break-continue-syntax-errors.js
comments-basic.js
computed-property-sideeffects.js
computed-property-throws.js
const-declaration-missing-initializer.js
const-reassignment.js
custom-@@hasInstance.js
custom-@@toPrimitive.js
custom-@@toStringTag.js
debugger-statement.js
duplicated-variable-declarations.js
empty-statements.js
eval-aliasing.js
eval-basic.js
exception-in-catch-block.js
exception-ReferenceError.js
exponentiation-basic.js
gc-deeply-nested-object-graph.js LibJS: Use a work queue instead of the C++ stack for the GC mark phase 2023-01-10 15:30:07 -05:00
global-var-let-const.js
if-statement-function-declaration.js
indexed-access-prototype-indirection.js
indexed-access-string-object.js
invalid-lhs-in-assignment.js LibJS: Allow CallExpressions as lhs of assignments in most cases 2022-11-30 08:05:37 +01:00
labels.js
let-scoping.js
new-expression.js
non-writable-assignment.js
numeric-literals-basic.js
object-basic.js LibJS: Don't update names of resulting functions in object expression 2022-12-14 15:27:08 +00:00
object-expression-__proto__.js
object-expression-computed-property.js
object-expression-numeric-property.js LibJS: Allow BigInts as destructuring property names 2022-08-24 23:27:17 +01:00
object-getter-setter-shorthand.js
object-method-shorthand.js
object-spread.js
ordinary-to-primitive.js
parseInt.js
parser-declaration-in-single-statement-context.js
parser-line-terminators.js
parser-unary-associativity.js
permanently-screwed-by-eval.js
program-non-strict.js
program-strict-mode.js
return.js
runtime-error-call-stack-size.js
statement-with-many-labels.js
strict-mode-blocks.js
strict-mode-errors.js
string-basic.js
string-concatenation.js
string-escapes.js
string-spread.js
switch-basic.js
switch-break.js
switch-default-before-case.js
tagged-template-literals.js LibJS: Use correct this value for tagged template calls 2022-11-15 12:00:36 +00:00
template-literals.js LibJS: Treat '\\' as an escaped character in template literals 2022-11-15 12:00:36 +00:00
test-common-tests.js
test-common.js LibJS: Add custom details to toBe{True, False} shown on failure 2023-01-23 09:56:50 +00:00
this-value-strict.js
this-value.js
throw-basic.js
to-number-basic.js
to-number-exception.js
try-catch-finally-nested.js
try-catch-finally-return.js
try-catch-finally.js
try-finally-break.js LibJS: Add thorough tests for try/finally using continue and break 2022-11-08 21:10:53 +00:00
try-finally-continue.js LibJS: Add thorough tests for try/finally using continue and break 2022-11-08 21:10:53 +00:00
unicode-identifier-escape.js
update-expression-on-member-expression.js
update-expressions-basic.js
use-strict-directive.js
using-declaration.js LibJS: Add using declaration support, RAII like operation in js 2023-01-23 09:56:50 +00:00
using-for-loops.js LibJS: Add using declaration support in for and for of loops 2023-01-23 09:56:50 +00:00
var-multiple-declarator.js
var-scoping.js
variable-undefined.js
with-basic.js