@@ -30,33 +30,6 @@ local function hasConflict(specA: projectmanifest.DependencySpec, specB: project
3030 return specA .rev ~= specB .rev or specA .source ~= specB .source or specA .sourceKind ~= specB .sourceKind
3131end
3232
33- local function findConflict (
34- spec : projectmanifest .DependencySpec ,
35- dependencies : { [string ]: projectmanifest .DependencySpec },
36- nameIndex : { [string ]: string }
37- ): string ?
38- local conflictKey = nameIndex [spec .name ]
39- if conflictKey and hasConflict (dependencies [conflictKey ], spec ) then
40- return conflictKey
41- end
42- return nil
43- end
44-
45- local function checkForConflict (
46- spec : projectmanifest .DependencySpec ,
47- dependencies : { [string ]: projectmanifest .DependencySpec },
48- nameIndex : { [string ]: string }
49- ): ()
50- local conflictKey = findConflict (spec , dependencies , nameIndex )
51- if conflictKey then
52- error (
53- `Version conflict for package '{spec .name }':\n `
54- .. ` but {conflictKey } is already resolved\n `
55- .. `Resolve by pinning both to the same revision.`
56- )
57- end
58- end
59-
6033local function createLockfile (resolved : ResolvedGraph ): lockfile .Lockfile
6134 local deps : { [string ]: lockfile .LockfileDependency } = {}
6235
@@ -99,8 +72,6 @@ local function resolve(rootDirectory: string): ResolvedGraph
9972 local dependencies : { [string ]: projectmanifest .DependencySpec } = {}
10073 local graph : { [string ]: { [string ]: string } } = {}
10174
102- local nameIndex : { [string ]: string } = {}
103-
10475 local rootManifest = projectmanifest .parseFile (rootManifestPath )
10576 for _ , spec in rootManifest .package .dependencies do
10677 table.insert (packages , getKey (spec ))
@@ -110,17 +81,22 @@ local function resolve(rootDirectory: string): ResolvedGraph
11081 table.freeze (packages )
11182
11283 for _ , spec in queue do
113- -- Check for version conflict (same name, different rev)
114- checkForConflict (spec , dependencies , nameIndex )
115-
11684 local key = getKey (spec )
85+
11786 if dependencies [key ] then
118- -- Already resolved at this exact version — deduplicate
119- continue
87+ if hasConflict (dependencies [key ], spec ) then
88+ error (
89+ `Version conflict for package '{spec .name }':\n `
90+ .. ` but {key } is already resolved\n `
91+ .. `Resolve by pinning both to the same revision.`
92+ )
93+ else
94+ -- Already resolved at this exact version — deduplicate
95+ continue
96+ end
12097 end
12198
12299 -- New package — resolve it
123- nameIndex [spec .name ] = key
124100 dependencies [key ] = spec
125101 graph [key ] = {}
126102
0 commit comments