mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-08-15 19:30:41 +03:00
Merge pull request #431 from Kindelia/experimental
Fixed string problems
This commit is contained in:
commit
8ec30579ca
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kind-cli"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
edition = "2021"
|
||||
description = "A pure functional functional language that uses the HVM."
|
||||
repository = "https://github.com/Kindelia/Kind2"
|
||||
|
@ -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);
|
||||
|
1
crates/kind-tests/suite/eval/issues/CallStr.golden
Normal file
1
crates/kind-tests/suite/eval/issues/CallStr.golden
Normal file
@ -0,0 +1 @@
|
||||
"ata"
|
3
crates/kind-tests/suite/eval/issues/CallStr.kind2
Normal file
3
crates/kind-tests/suite/eval/issues/CallStr.kind2
Normal file
@ -0,0 +1,3 @@
|
||||
Main : U60 {
|
||||
"ata"
|
||||
}
|
@ -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