Handle non simple refs in chained expressions (#182)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-03-15 07:13:54 -07:00
committed by GitHub
parent 48982222c5
commit 7e3fc08a14
3 changed files with 22 additions and 9 deletions
+2 -1
View File
@@ -190,11 +190,12 @@ pub fn gather_functions(modules: &[Ref<Module>]) -> Result<FunctionTable> {
}
pub fn get_root_var(mut expr: &Expr) -> Result<SourceStr> {
let empty = expr.span().source_str().clone_empty();
loop {
match expr {
Expr::Var(v) => return Ok(v.source_str()),
Expr::RefDot { refr, .. } | Expr::RefBrack { refr, .. } => expr = refr,
_ => bail!("internal error: analyzer: could not get rule prefix"),
_ => return Ok(empty),
}
}
}