mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:42:43 +00:00 
			
		
		
		
	 0fc67ffd62
			
		
	
	
		0fc67ffd62
		
	
	
	
	
		
			
			Before this we attempted to hack around this by only overriding has_binding. However this did not cover all cases, for example when assigning to variables before their declaration it didn't throw. By using the new find_binding_and_index virtual method we can just pretend the indirect bindings are real. Since indirect binding do come from a normal environment we need to ensure you cannot modify the binding and that properties like mutable are false as expected by the spec for such an indirect binding.
		
			
				
	
	
		
			23 lines
		
	
	
	
		
			639 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
	
		
			639 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| let passed = true;
 | |
| 
 | |
| try {
 | |
|     importedLexVariable;
 | |
|     passed = false;
 | |
| } catch (e) {
 | |
|     if (!(e instanceof ReferenceError))
 | |
|         throw new Error("Expected importedLexVariable; to throw ReferenceError got " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     // Even though value is let, this should still throw TypeError because it is immutable!
 | |
|     importedLexVariable = 0;
 | |
|     passed = false;
 | |
| } catch (e) {
 | |
|     if (!(e instanceof TypeError))
 | |
|         throw new Error("Expected importedLexVariable = 0; to throw TypeError got " + e);
 | |
| }
 | |
| 
 | |
| import { value as importedLexVariable } from "./accessing-lex-import-before-decl.mjs";
 | |
| export let value = 123;
 | |
| 
 | |
| export { passed };
 |