Add index to Share statement.

This commit is contained in:
Stephen Chung
2022-10-25 10:05:31 +08:00
parent 6880d44900
commit 6702fe349c
5 changed files with 25 additions and 14 deletions

View File

@@ -3711,7 +3711,10 @@ impl Engine {
statements.extend(
externals
.into_iter()
.map(|crate::ast::Ident { name, pos }| Stmt::Share(name, pos)),
.map(|crate::ast::Ident { name, pos }| {
let (index, _) = parent.access_var(&name, lib, pos);
Stmt::Share((name, index).into(), pos)
}),
);
statements.push(Stmt::Expr(expr.into()));
Expr::Stmt(crate::ast::StmtBlock::new(statements, pos, Position::NONE).into())