mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:22:45 +00:00 
			
		
		
		
	LibJS: Only check for duplicate exports if they have a name
Together with removing an incorrect VERIFY this allows multiple star imports in a single module.
This commit is contained in:
		
							parent
							
								
									3b56043612
								
							
						
					
					
						commit
						462c6df24b
					
				
					 4 changed files with 9 additions and 3 deletions
				
			
		|  | @ -4498,7 +4498,7 @@ bool ExportStatement::has_export(FlyString const& export_name) const | ||||||
| { | { | ||||||
|     return any_of(m_entries.begin(), m_entries.end(), [&](auto& entry) { |     return any_of(m_entries.begin(), m_entries.end(), [&](auto& entry) { | ||||||
|         // Make sure that empty exported names does not overlap with anything
 |         // Make sure that empty exported names does not overlap with anything
 | ||||||
|         if (entry.kind == ExportEntry::Kind::EmptyNamedExport) |         if (entry.kind != ExportEntry::Kind::NamedExport) | ||||||
|             return false; |             return false; | ||||||
|         return entry.export_name == export_name; |         return entry.export_name == export_name; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -202,8 +202,6 @@ Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> SourceTextModule: | ||||||
|                     // 2. If ie.[[ImportName]] is namespace-object, then
 |                     // 2. If ie.[[ImportName]] is namespace-object, then
 | ||||||
|                     if (import_entry.is_namespace) { |                     if (import_entry.is_namespace) { | ||||||
|                         // a. NOTE: This is a re-export of an imported module namespace object.
 |                         // a. NOTE: This is a re-export of an imported module namespace object.
 | ||||||
|                         VERIFY(export_entry.is_module_request() && export_entry.kind != ExportStatement::ExportEntry::Kind::NamedExport); |  | ||||||
| 
 |  | ||||||
|                         // b. Append ee to localExportEntries.
 |                         // b. Append ee to localExportEntries.
 | ||||||
|                         local_export_entries.empend(export_entry); |                         local_export_entries.empend(export_entry); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  | @ -186,6 +186,10 @@ describe("in- and exports", () => { | ||||||
|     test("namespace has expected ordering", () => { |     test("namespace has expected ordering", () => { | ||||||
|         expectModulePassed("./namespace-order.mjs"); |         expectModulePassed("./namespace-order.mjs"); | ||||||
|     }); |     }); | ||||||
|  | 
 | ||||||
|  |     test("can have multiple star imports even from the same file", () => { | ||||||
|  |         expectModulePassed("./multiple-star-imports.mjs"); | ||||||
|  |     }); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| describe("loops", () => { | describe("loops", () => { | ||||||
|  |  | ||||||
|  | @ -0,0 +1,4 @@ | ||||||
|  | import * as ns1 from "./default-and-star-export.mjs"; | ||||||
|  | import * as ns2 from "./default-and-star-export.mjs"; | ||||||
|  | 
 | ||||||
|  | export const passed = ns1 === ns2; | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 davidot
						davidot