mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:02:44 +00:00 
			
		
		
		
	 2d8b2328fd
			
		
	
	
		2d8b2328fd
		
	
	
	
	
		
			
			This change makes LibJS correctly report a syntax error when a unary
expression is followed by exponentiation, as the spec requires.
Apparently this is due to that expression being ambiguous ordering.
Strangely this check does not seem to apply in the same way for '++' and
'--' for reasons that I don't fully understand. For example
```
let x = 5;
++x ** 2
```
Since `--5` and `++5` on it's own results in a syntax error anyway, it
seems we do not need to perform this exponentiation check in those
places.
Diff Tests:
    +6 ✅    -6 ❌
		
	
			
		
			
				
	
	
		
			9 lines
		
	
	
	
		
			347 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			9 lines
		
	
	
	
		
			347 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("syntax error for an unary expression before exponentiation", () => {
 | |
|     expect(`!5 ** 2`).not.toEval();
 | |
|     expect(`~5 ** 2`).not.toEval();
 | |
|     expect(`+5 ** 2`).not.toEval();
 | |
|     expect(`-5 ** 2`).not.toEval();
 | |
|     expect(`typeof 5 ** 2`).not.toEval();
 | |
|     expect(`void 5 ** 2`).not.toEval();
 | |
|     expect(`delete 5 ** 2`).not.toEval();
 | |
| });
 |