mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:52:43 +00:00 
			
		
		
		
	 80bb62b9cc
			
		
	
	
		80bb62b9cc
		
	
	
	
	
		
			
			This separates matching/parsing of statements and declarations and
fixes a few edge cases where the parser would incorrectly accept a
declaration where only a statement is allowed - for example:
    if (foo) const a = 1;
    for (var bar;;) function b() {}
    while (baz) class c {}
		
	
			
		
			
				
	
	
		
			6 lines
		
	
	
	
		
			293 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			6 lines
		
	
	
	
		
			293 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("Declaration in single-statement context is a syntax error", () => {
 | |
|     expect("if (0) const foo = 1").not.toEval();
 | |
|     expect("while (0) function foo() {}").not.toEval();
 | |
|     expect("for (var 0;;) class foo() {}").not.toEval();
 | |
|     expect("do let foo = 1 while (0)").not.toEval();
 | |
| });
 |