Accept redundant alias definitions.
In the text format, allow aliases to be defined multiple times, as long as they're always aliasing the same value. write.rs is already emitting redundant aliases, because it emits them at their uses, so this change allows the parser to be able to parse such code.
This commit is contained in:
@@ -949,6 +949,18 @@ impl DataFlowGraph {
|
||||
self.values[dest] = data;
|
||||
}
|
||||
|
||||
/// If `v` is already defined as an alias, return its destination value.
|
||||
/// Otherwise return None. This allows the parser to coalesce identical
|
||||
/// alias definitions.
|
||||
#[cold]
|
||||
pub fn value_alias_dest_for_parser(&self, v: Value) -> Option<Value> {
|
||||
if let ValueData::Alias { original, .. } = self.values[v] {
|
||||
Some(original)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the type of an alias. This is only for use in the parser.
|
||||
/// Returns false if an alias cycle was encountered.
|
||||
#[cold]
|
||||
|
||||
Reference in New Issue
Block a user