Add position info for closures.

This commit is contained in:
Stephen Chung
2022-02-09 13:40:51 +08:00
parent 340a047369
commit e5a673b3ae
4 changed files with 39 additions and 28 deletions

View File

@@ -376,7 +376,7 @@ pub enum Stmt {
/// This variant does not map to any language structure. It is currently only used only to
/// convert a normal variable into a shared variable when the variable is _captured_ by a closure.
#[cfg(not(feature = "no_closure"))]
Share(crate::Identifier),
Share(crate::Identifier, Position),
}
impl Default for Stmt {
@@ -427,7 +427,7 @@ impl Stmt {
Self::Export(.., pos) => *pos,
#[cfg(not(feature = "no_closure"))]
Self::Share(..) => Position::NONE,
Self::Share(.., pos) => *pos,
}
}
/// Override the [position][Position] of this statement.
@@ -458,7 +458,7 @@ impl Stmt {
Self::Export(.., pos) => *pos = new_pos,
#[cfg(not(feature = "no_closure"))]
Self::Share(..) => (),
Self::Share(.., pos) => *pos = new_pos,
}
self