From a13b1e2847a55138bec434599aed33f3864bfd3c Mon Sep 17 00:00:00 2001 From: tiye Date: Sat, 10 Jun 2023 12:00:47 +0800 Subject: [PATCH] more warning on unresolved symbol; tag 0.7.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- calcit/test-cond.cirru | 6 +++--- package.json | 2 +- src/runner/preprocess.rs | 18 ++++++++++++------ ts-src/calcit.procs.mts | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 347ff2f8..1f62f806 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,7 +36,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "calcit" -version = "0.7.0-a7" +version = "0.7.0" dependencies = [ "cirru_edn", "cirru_parser", diff --git a/Cargo.toml b/Cargo.toml index 66fc9539..02b81658 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "calcit" -version = "0.7.0-a7" +version = "0.7.0" authors = ["jiyinyiyong "] edition = "2021" license = "MIT" diff --git a/calcit/test-cond.cirru b/calcit/test-cond.cirru index 10d56291..16ab5d06 100644 --- a/calcit/test-cond.cirru +++ b/calcit/test-cond.cirru @@ -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= diff --git a/package.json b/package.json index 5b005a15..9abb82ea 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/runner/preprocess.rs b/src/runner/preprocess.rs index 1d557add..5a3896ca 100644 --- a/src/runner/preprocess.rs +++ b/src/runner/preprocess.rs @@ -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, }; @@ -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 { @@ -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)) } } ( @@ -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 @@ -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 { @@ -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, diff --git a/ts-src/calcit.procs.mts b/ts-src/calcit.procs.mts index 6110dc99..10310037 100644 --- a/ts-src/calcit.procs.mts +++ b/ts-src/calcit.procs.mts @@ -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";