Skip to content

Commit

Permalink
Merge pull request #211 from calcit-lang/warning
Browse files Browse the repository at this point in the history
more warning on unresolved symbol
  • Loading branch information
csvwolf committed Jun 12, 2023
2 parents 4c8d1ef + a13b1e2 commit a409d9f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit"
version = "0.7.0-a7"
version = "0.7.0"
authors = ["jiyinyiyong <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions calcit/test-cond.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@
(:b x y) (' "|pattern b:" x y)
_ (' "|no match")
assert=
match-ab (' :a 1 2)
match-ab (:: :a 1)
[] "|pattern a:" 1
assert=
match-ab (' :b 1 2)
match-ab ([] :b 1 2)
[] "|pattern b:" 1 2
assert=
match-ab (' :c 1 2)
match-ab (:: :c 1 2)
[] "|no match"

assert=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.7.0-a7",
"version": "0.7.0",
"main": "./lib/calcit.procs.mjs",
"devDependencies": {
"@types/node": "^20.2.5",
Expand Down
18 changes: 12 additions & 6 deletions src/runner/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
call_stack::{extend_call_stack, CalcitStack, CallStackList, StackKind},
primes,
primes::{
Calcit, CalcitErr, CalcitItems, CalcitProc, CalcitScope, CalcitSyntax, ImportRule, LocatedWarning, NodeLocation, RawCodeType,
SymbolResolved::*, GENERATED_DEF,
Calcit, CalcitErr, CalcitItems, CalcitProc, CalcitScope, CalcitSyntax, CrListWrap, ImportRule, LocatedWarning, NodeLocation,
RawCodeType, SymbolResolved::*, GENERATED_DEF,
},
program, runner,
};
Expand Down Expand Up @@ -324,6 +324,7 @@ fn process_list_call(
// Keyword: transforming into tag expression
// Syntax: handled directly during preprocessing
// Thunk: invalid here

match (&head_form, &head_evaled) {
(Calcit::Tag(..), _) => {
if args.len() == 1 {
Expand All @@ -344,7 +345,7 @@ fn process_list_call(
]));
preprocess_expr(&code, scope_defs, file_ns, check_warnings, call_stack)
} else {
Err(CalcitErr::use_msg_stack(format!("{head} expected single argument"), call_stack))
Err(CalcitErr::use_msg_stack(format!("{head} expected 1 hashmap to call"), call_stack))
}
}
(
Expand Down Expand Up @@ -391,7 +392,7 @@ fn process_list_call(
None,
)),
CalcitSyntax::CoreLet => Ok((
preprocess_call_let(name, name_ns.to_owned(), &args, scope_defs, file_ns, check_warnings, call_stack)?,
preprocess_core_let(name, name_ns.to_owned(), &args, scope_defs, file_ns, check_warnings, call_stack)?,
None,
)),
CalcitSyntax::If
Expand Down Expand Up @@ -443,7 +444,12 @@ fn process_list_call(
}
Ok((Calcit::List(TernaryTreeList::from(&ys)), None))
}
(_, _) => {
(h, he) => {
if let Calcit::Symbol { sym, resolved, .. } = h {
if he.is_none() && resolved.is_none() && !is_js_syntax_procs(sym) {
println!("warning: unresolved symbol `{}` in `{}`", sym, CrListWrap(xs.to_owned()));
}
}
let mut ys = Vec::with_capacity(args.len() + 1);
ys.push(head_form);
for a in &args {
Expand Down Expand Up @@ -660,7 +666,7 @@ fn check_symbol(sym: &str, args: &CalcitItems, location: NodeLocation, check_war
}
}

pub fn preprocess_call_let(
pub fn preprocess_core_let(
head: &CalcitSyntax,
// where the symbol was defined
head_ns: Arc<str>,
Expand Down
2 changes: 1 addition & 1 deletion ts-src/calcit.procs.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// CALCIT VERSION
export const calcit_version = "0.7.0-a7";
export const calcit_version = "0.7.0";

import { parse, ICirruNode } from "@cirru/parser.ts";
import { writeCirruCode } from "@cirru/writer.ts";
Expand Down

0 comments on commit a409d9f

Please sign in to comment.