feat(natu): report expected let order
This commit was merged in pull request #102.
This commit is contained in:
@@ -26,7 +26,11 @@ impl ScopeGraph {
|
||||
fn build_expr(&mut self, expr: &ast::Expr, scope: NodeId) -> Vec<NodeId> {
|
||||
match expr {
|
||||
ast::Expr::Ident(ident) => vec![self.add_reference(&ident.name, scope)],
|
||||
ast::Expr::Let { bindings, body } => self.build_let(bindings, body, scope),
|
||||
ast::Expr::Let {
|
||||
range,
|
||||
bindings,
|
||||
body,
|
||||
} => self.build_let(*range, bindings, body, scope),
|
||||
ast::Expr::AttrSet(bindings) => bindings
|
||||
.iter()
|
||||
.flat_map(|binding| self.build_expr(&binding.value, scope))
|
||||
@@ -48,6 +52,7 @@ impl ScopeGraph {
|
||||
|
||||
fn build_let(
|
||||
&mut self,
|
||||
range: ast::SourceRange,
|
||||
bindings: &[ast::Binding],
|
||||
body: &ast::Expr,
|
||||
parent: NodeId,
|
||||
@@ -59,7 +64,6 @@ impl ScopeGraph {
|
||||
declaration: self.add_declaration(&binding.key.name, scope),
|
||||
name: binding.key.name.clone(),
|
||||
references: Vec::new(),
|
||||
range: binding.range,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -74,6 +78,7 @@ impl ScopeGraph {
|
||||
.chain(entry_references.iter().copied())
|
||||
.collect();
|
||||
self.lets.push(LetScope {
|
||||
range,
|
||||
bindings: graph_bindings,
|
||||
entry_references,
|
||||
});
|
||||
@@ -181,6 +186,7 @@ struct Edge {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct LetScope {
|
||||
pub(crate) range: ast::SourceRange,
|
||||
pub(crate) bindings: Vec<Binding>,
|
||||
pub(crate) entry_references: Vec<NodeId>,
|
||||
}
|
||||
@@ -190,5 +196,4 @@ pub(crate) struct Binding {
|
||||
pub(crate) declaration: NodeId,
|
||||
pub(crate) name: String,
|
||||
pub(crate) references: Vec<NodeId>,
|
||||
pub(crate) range: ast::SourceRange,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user