-
Notifications
You must be signed in to change notification settings - Fork 13
feat!: No nested FuncDefns (or AliasDefns) #2256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 34 commits
9f4bcbb
6f2121f
7ea2c16
cd2be05
85f312d
d9bd2dc
e20d5bb
844adf6
7098652
ed2d90b
5c3d8c0
11d7c59
6b282a9
9f7076a
56a5f34
5d202e9
1ae84a4
b2758ce
d25c03c
7e2be32
090f9c7
12cf781
1986a1a
cc08b0c
fa32fc5
54a0821
055fc6e
5932b23
4949b22
bc31027
37f827c
9f4bf09
a32f509
5441ac1
e507db3
2686d6d
724f6e9
6174928
095770c
372afb5
90472fd
108dbad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,8 +332,10 @@ impl Hugr { | |
| self.hierarchy.swap_nodes(pg_target, pg_source); | ||
| rekey(source, target); | ||
|
|
||
| if source.into_portgraph() == self.entrypoint { | ||
| if source.into_portgraph() == new_entrypoint { | ||
| new_entrypoint = target.into_portgraph(); | ||
| } else if target.into_portgraph() == new_entrypoint { | ||
|
||
| new_entrypoint = source.into_portgraph(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -443,28 +443,12 @@ impl<'a, H: HugrView> ValidationContext<'a, H> { | |
| // | ||
| // This search could be sped-up with a pre-computed LCA structure, but | ||
| // for valid Hugrs this search should be very short. | ||
| // | ||
| // For Value edges only, we record any FuncDefn we went through; if there is | ||
| // any such, then that is an error, but we report that only if the dom/ext | ||
| // relation was otherwise ok (an error about an edge "entering" some ancestor | ||
| // node could be misleading if the source isn't where it's expected) | ||
| let mut err_entered_func = None; | ||
| let from_parent_parent = self.hugr.get_parent(from_parent); | ||
| for (ancestor, ancestor_parent) in | ||
| iter::successors(to_parent, |&p| self.hugr.get_parent(p)).tuple_windows() | ||
| { | ||
| if !is_static && self.hugr.get_optype(ancestor).is_func_defn() { | ||
| err_entered_func.get_or_insert(InterGraphEdgeError::ValueEdgeIntoFunc { | ||
| to, | ||
| to_offset, | ||
| from, | ||
| from_offset, | ||
| func: ancestor, | ||
| }); | ||
| } | ||
| if ancestor_parent == from_parent { | ||
| // External edge. | ||
| err_entered_func.map_or(Ok(()), Err)?; | ||
| if !is_static { | ||
| // Must have an order edge. | ||
| self.hugr | ||
|
|
@@ -491,7 +475,7 @@ impl<'a, H: HugrView> ValidationContext<'a, H> { | |
| ancestor_parent_op: ancestor_parent_op.clone(), | ||
| }); | ||
| } | ||
| err_entered_func.map_or(Ok(()), Err)?; | ||
|
|
||
| // Check domination | ||
| let (dominator_tree, node_map) = | ||
| if let Some(tree) = self.dominators.get(&ancestor_parent) { | ||
|
|
@@ -759,6 +743,7 @@ pub enum InterGraphEdgeError<N: HugrNode> { | |
| ty: EdgeKind, | ||
| }, | ||
| /// Inter-Graph edges may not enter into `FuncDefns` unless they are static | ||
| #[deprecated(note = "FuncDefns at top level only so cannot occur")] | ||
|
||
| #[error( | ||
| "Inter-graph Value edges cannot enter into FuncDefns. Inter-graph edge from {from} ({from_offset}) to {to} ({to_offset} enters FuncDefn {func}" | ||
| )] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment not for committing (but perhaps the rest) - see PR comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With that utility can we avoid a breakage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the breakage is avoidable by code duplication between the deprecated and new versions but I suspect not any other way...neither
module_root_buildernor the utility suggested here help, no.