mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	LibJS: Fix "use strict" directive false positives
By having the "is this a use strict directive?" logic in
parse_string_literal() we would apply it to *any* string literal, which
is incorrect and would lead to false positives - e.g.:
    "use strict" + 1
    `"use strict"`
    "\123"; ({"use strict": ...})
Relevant part from the spec which is now implemented properly:
[...] and where each ExpressionStatement in the sequence consists
entirely of a StringLiteral token [...]
I also got rid of UseStrictDirectiveState which is not needed anymore.
Fixes #3903.
			
			
This commit is contained in:
		
							parent
							
								
									21912123c4
								
							
						
					
					
						commit
						9e80c67608
					
				
					 4 changed files with 54 additions and 55 deletions
				
			
		|  | @ -45,4 +45,16 @@ test("invalid 'use strict; directive", () => { | |||
|             return isStrictMode(); | ||||
|         })() | ||||
|     ).toBeFalse(); | ||||
|     expect( | ||||
|         (() => { | ||||
|             `"use strict"`; | ||||
|             return isStrictMode(); | ||||
|         })() | ||||
|     ).toBeFalse(); | ||||
|     expect( | ||||
|         (() => { | ||||
|             "use strict" + 1; | ||||
|             return isStrictMode(); | ||||
|         })() | ||||
|     ).toBeFalse(); | ||||
| }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh