-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core/toposort: Correct CloseInfo Decl
Toposort depends on StructInfos in Vertices to include the Decl which contains the StructInfo. It uses this to establish a parent-child relationship which enables it to walk topologically over the StructLits which contributed to a Vertex. In evalv3, when creating a StructInfo, the closeContext may contain the Decl we want. In evalv2, when creating a StructInfo, the closeInfo may contain the Decl we want, but this code was previously faulty: if the closeInfo had a nil Decl, then we would search parent closeInfos. This is faulty because it could feed into toposort the notion that a Decl is its own parent, which leads to infinite loop and stack explosion. Removing the search through any parent closeInfo solves this problem. The effect of this actually reduces the difference for toposort between evalv2 and evalv3, so it is beneficial in this regard too. Fixes #3710. Signed-off-by: Matthew Sackman <[email protected]> Change-Id: I8a8e7c0e83386c20428bd2d8723d5b24f5181677 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207989 Reviewed-by: Marcel van Lohuizen <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information
1 parent
870bfc2
commit db9cc73
Showing
8 changed files
with
79 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- input.cue -- | ||
package p | ||
|
||
#Exporter: { | ||
_objects: {...} | ||
_imports: [...] | ||
|
||
objects: [ | ||
for _, objs in _objects { | ||
objs | ||
} | ||
for import in _imports for obj in import._export.objects { | ||
obj | ||
} | ||
] | ||
} | ||
|
||
out: #Exporter & { | ||
_imports: [_app1] | ||
} | ||
_app1: { | ||
_export: #Exporter & { | ||
_imports: [_app2] | ||
} | ||
} | ||
_app2: { | ||
_export: #Exporter & { | ||
_objects: leaf: leafField: "leaf value" | ||
} | ||
} | ||
-- out/TestTopologicalSort/lexicographical=false -- | ||
{ | ||
#Exporter: { | ||
objects: [] | ||
} | ||
out: { | ||
objects: [{ | ||
leafField: "leaf value" | ||
}] | ||
} | ||
} | ||
-- out/TestTopologicalSort/lexicographical=true -- | ||
{ | ||
#Exporter: { | ||
objects: [] | ||
} | ||
out: { | ||
objects: [{ | ||
leafField: "leaf value" | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters