cl-ast: Remove Param, replace with flat Pattern

This commit is contained in:
2025-02-23 02:01:38 -06:00
parent e3d94d8949
commit cc6168b55e
10 changed files with 16 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
//! Collects the "Upvars" of a function at the point of its creation, allowing variable capture
use crate::{convalue::ConValue, env::Environment};
use cl_ast::{ast_visitor::visit::*, Function, Let, Param, Path, PathPart, Pattern, Sym};
use cl_ast::{ast_visitor::visit::*, Function, Let, Path, PathPart, Pattern, Sym};
use std::collections::{HashMap, HashSet};
pub fn collect_upvars(f: &Function, env: &Environment) -> super::Upvars {
@@ -67,9 +67,7 @@ impl<'a> Visit<'a> for CollectUpvars<'_> {
fn visit_function(&mut self, f: &'a cl_ast::Function) {
let Function { name: _, sign: _, bind, body } = f;
// parameters can never be upvars
for Param { mutability: _, bind } in bind {
self.visit_pattern(bind);
}
bind.iter().for_each(|pat| self.visit_pattern(pat));
if let Some(body) = body {
self.visit_expr(body);
}