mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-09-11 08:45:32 +03:00
fix: string cons and nil are called when string is required
This commit is contained in:
parent
ff900370f8
commit
6724c8dff3
@ -182,7 +182,7 @@ impl<'a> Visitor for Subst<'a> {
|
||||
self.visit_expr(val);
|
||||
self.visit_expr(typ);
|
||||
}
|
||||
ExprKind::Lit { lit } => self.visit_literal(lit),
|
||||
ExprKind::Lit { lit } => self.visit_literal(expr.range, lit),
|
||||
ExprKind::Binary { op: _, fst, snd } => {
|
||||
self.visit_expr(fst);
|
||||
self.visit_expr(snd);
|
||||
|
@ -334,7 +334,11 @@ impl Visitor for UnboundCollector {
|
||||
fn visit_pat(&mut self, pat: &mut Pat) {
|
||||
match &mut pat.data {
|
||||
PatKind::Var(ident) => self.visit_pat_ident(ident),
|
||||
PatKind::Str(_) => (),
|
||||
PatKind::Str(_) => {
|
||||
let string = &mut QualifiedIdent::new_static("String", None, pat.range);
|
||||
self.visit_qualified_ident(&mut string.add_segment("cons").to_generated());
|
||||
self.visit_qualified_ident(&mut string.add_segment("nil").to_generated());
|
||||
}
|
||||
PatKind::U60(_) => (),
|
||||
PatKind::U120(_) => (),
|
||||
PatKind::F60(_) => (),
|
||||
@ -393,6 +397,19 @@ impl Visitor for UnboundCollector {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_literal(&mut self, range: Range, lit: &mut kind_tree::concrete::Literal) {
|
||||
use kind_tree::concrete::Literal::*;
|
||||
|
||||
match lit {
|
||||
String(_) => {
|
||||
let string = &mut QualifiedIdent::new_static("String", None, range);
|
||||
self.visit_qualified_ident(&mut string.add_segment("cons").to_generated());
|
||||
self.visit_qualified_ident(&mut string.add_segment("nil").to_generated());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &mut Expr) {
|
||||
match &mut expr.data {
|
||||
ExprKind::Var { name } => self.visit_ident(name),
|
||||
@ -439,7 +456,7 @@ impl Visitor for UnboundCollector {
|
||||
self.visit_expr(val);
|
||||
self.visit_expr(typ);
|
||||
}
|
||||
ExprKind::Lit { lit } => self.visit_literal(lit),
|
||||
ExprKind::Lit { lit } => self.visit_literal(expr.range, lit),
|
||||
ExprKind::Binary { op: _, fst, snd } => {
|
||||
self.visit_expr(fst);
|
||||
self.visit_expr(snd);
|
||||
|
@ -56,8 +56,8 @@ pub trait Visitor: Sized {
|
||||
walk_syntax_ctx(self, synt);
|
||||
}
|
||||
|
||||
fn visit_literal(&mut self, lit: &mut Literal) {
|
||||
walk_literal(self, lit);
|
||||
fn visit_literal(&mut self, range: Range, lit: &mut Literal) {
|
||||
walk_literal(self, range, lit);
|
||||
}
|
||||
|
||||
fn visit_pat_ident(&mut self, ident: &mut PatIdent) {
|
||||
@ -145,7 +145,7 @@ pub fn walk_range<T: Visitor>(_: &mut T, _: &mut Range) {}
|
||||
|
||||
pub fn walk_syntax_ctx<T: Visitor>(_: &mut T, _: &mut SyntaxCtxIndex) {}
|
||||
|
||||
pub fn walk_literal<T: Visitor>(_: &mut T, _: &mut Literal) {}
|
||||
pub fn walk_literal<T: Visitor>( _: &mut T, _: Range, _: &mut Literal) {}
|
||||
|
||||
pub fn walk_constructor<T: Visitor>(ctx: &mut T, cons: &mut Constructor) {
|
||||
ctx.visit_ident(&mut cons.name);
|
||||
@ -463,7 +463,7 @@ pub fn walk_expr<T: Visitor>(ctx: &mut T, expr: &mut Expr) {
|
||||
ctx.visit_expr(typ);
|
||||
}
|
||||
ExprKind::Lit { lit } => {
|
||||
ctx.visit_literal(lit);
|
||||
ctx.visit_literal(expr.range, lit);
|
||||
}
|
||||
ExprKind::Binary { op: _, fst, snd } => {
|
||||
ctx.visit_expr(fst);
|
||||
|
Loading…
Reference in New Issue
Block a user