fix: prototype-aware binding lookup for nested let

Add binding-get helper that walks Janet table prototype chain.
resolve-sym now uses two-stage lookup: direct get first,
then prototype walk as fallback. This fixes access to outer
let bindings from inner let forms without breaking fn parameter
resolution (which uses direct table keys).

All 9 test suites pass including macro-test.
This commit is contained in:
Yogthos 2026-06-02 12:02:57 -04:00
parent 33a5b7e7a4
commit 677d059c0b
4 changed files with 60 additions and 2 deletions

View file

@ -0,0 +1 @@
["^ ","~$copy-before",["^ ","~:fixed-arities",["~#set",[3]],"~:private",true,"~:ns","~$jolt.lang.persistent-hash-map","~:name","^0","~:type","~:fn","~:col",1,"~:top-ns","^5","~:row",30],"~$hash-mix",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^<","^7","^8","^9",1,"^:","^5","~:arities",["^ ","~i1",["^ ","~:ret",["^2",["~:number"]],"~:arglist-str","[h]"]],"^;",12],"~$bmn-without",["^ ","^1",["^2",[4]],"^3",true,"^4","^5","^6","^A","^7","^8","^9",1,"^:","^5","^;",102],"~$bit-count",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^B","^7","^8","^9",1,"^:","^5","^;",22],"~$phm-empty",["^ ","^;",179,"^9",1,"^1",["^2",[1]],"^6","^C","^4","^5","^:","^5","^7","^8"],"~$phm-count",["^ ","^;",178,"^9",1,"^1",["^2",[1]],"^6","^D","^4","^5","^:","^5","^7","^8"],"~$mask",["^ ","^1",["^2",[2]],"^3",true,"^4","^5","^6","^E","^7","^8","^9",1,"^:","^5","^=",["^ ","~i2",["^ ","^>","~:int","^@","[h sh]"]],"^;",16],"~$->BitmapIndexedNode",["^ ","^;",7,"^9",1,"^1",["^2",[2]],"^6","^G","^4","^5","^:","^5"],"~$index",["^ ","^1",["^2",[2]],"^3",true,"^4","^5","^6","^H","^7","^8","^9",1,"^:","^5","^;",26],"~$bmn-assoc",["^ ","^1",["^2",[6]],"^3",true,"^4","^5","^6","^I","^7","^8","^9",1,"^:","^5","^;",44],"~$PersistentHashMap",["^ ","^;",8,"^9",1,"^6","^J","^4","^5","^:","^5","~:class",true],"~$phm-assoc",["^ ","^;",134,"^9",1,"^1",["^2",[3]],"^6","^L","^4","^5","^:","^5","^7","^8"],"~$->PersistentHashMap",["^ ","^;",8,"^9",1,"^1",["^2",[5]],"^6","^M","^4","^5","^:","^5"],"~:filename","/Users/yogthos/src/jolt/src/jolt/clojure/lang/persistent_hash_map.clj","~$shift-increment",["^ ","^;",5,"^9",1,"^6","^O","^4","^5","^:","^5","^7","~:pos-int"],"~$phm-without",["^ ","^;",148,"^9",1,"^1",["^2",[2]],"^6","^Q","^4","^5","^:","^5","^7","^8"],"~$BitmapIndexedNode",["^ ","^;",7,"^9",1,"^6","^R","^4","^5","^:","^5","^K",true],"~$copy-after",["^ ","^1",["^2",[5]],"^3",true,"^4","^5","^6","^S","^7","^8","^9",1,"^:","^5","^;",38],"~$bitpos",["^ ","^1",["^2",[2]],"^3",true,"^4","^5","^6","^T","^7","^8","^9",1,"^:","^5","^;",19],"~$branch-factor",["^ ","^;",4,"^9",1,"^6","^U","^4","^5","^:","^5","^7","^P"],"~$phm-get",["^ ","^;",161,"^9",1,"^1",["^2",[3,2]],"^6","^V","^4","^5","^:","^5","^7","^8"],"~$phm-contains?",["^ ","^;",171,"^9",1,"^1",["^2",[2]],"^6","^W","^4","^5","^:","^5","^7","^8"],"~$hash-map",["^ ","^;",181,"^9",1,"~:varargs-min-arity",0,"^6","^X","^4","^5","^:","^5","^7","^8"],"~$not-found",["^ ","^;",10,"^9",1,"^6","^Z","^4","^5","^:","^5"],"~$EMPTY",["^ ","^;",14,"^9",1,"^6","^[","^4","^5","^:","^5"],"~$bmn-find",["^ ","^1",["^2",[4]],"^3",true,"^4","^5","^6","^10","^7","^8","^9",1,"^:","^5","^;",88]]

View file

@ -1 +1 @@
["^ ","~$load-persistent-structures",["^ ","~:fixed-arities",["~#set",[1]],"~:private",true,"~:ns","~$user","~:name","^0","~:type","~:fn","~:col",1,"~:top-ns",null,"~:row",9],"~$source",["^ ","^;",13,"^9",3,"^6","^<","^4","^5","^:",null],"~$init",["^ ","^;",26,"^9",1,"^1",["^2",[2]],"^6","^=","^4","^5","^:",null,"^7","^8"],"~$eval-string",["^ ","^;",46,"^9",1,"^1",["^2",[2]],"^6","^>","^4","^5","^:",null,"^7","^8"],"~$eval-string*",["^ ","^;",55,"^9",1,"^1",["^2",[3]],"^6","^?","^4","^5","^:",null,"^7","^8"],"~:filename","/Users/yogthos/src/jolt/src/jolt/api.janet"]
["^ ","~$binding-get",["^ ","~:fixed-arities",["~#set",[2]],"~:private",true,"~:ns","~$user","~:name","^0","~:type","~:fn","~:col",1,"~:top-ns",null,"~:row",101],"~$eval-list",["^ ","^1",["^2",[3]],"^3",true,"^4","^5","^6","^<","^7","^8","^9",1,"^:",null,"^;",216],"~$resolve-var",["^ ","^;",57,"^9",1,"^1",["^2",[3]],"^6","^=","^4","^5","^:",null,"^7","^8"],"~$syntax-quote*",["^ ","^1",["^2",[3]],"^3",true,"^4","^5","^6","^>","^7","^8","^9",1,"^:",null,"^;",22],"~$new-v",["^ ","^;",504,"^9",22,"^6","^?","^4","^5","^:",null],"~$ctor",["^ ","^;",585,"^9",17,"~:varargs-min-arity",0,"^6","^@","^4","^5","^:",null,"^7","^8"],"~$v",["^ ","^;",277,"^9",20,"^6","~$v","^4","^5","^:",null],"~$resolve-sym",["^ ","^1",["^2",[3]],"^3",true,"^4","^5","^6","^B","^7","^8","^9",1,"^:",null,"^;",113],"~$first-form",["^ ","^;",218,"^9",3,"^6","^C","^4","^5","^:",null,"^7","~:any"],"~$run-finally",["^ ","^;",458,"^9",13,"^1",["^2",[1]],"^6","^E","^4","^5","^:",null,"^7","^8"],"~$eval-require",["^ ","^1",["^2",[2]],"^3",true,"^4","^5","^6","^F","^7","^8","^9",1,"^:",null,"~:arities",["^ ","~i2",["^ ","~:ret","~:nil","~:arglist-str","[ctx spec]"]],"^;",74],"~$bind-put",["^ ","^1",["^2",[3]],"^3",true,"^4","^5","^6","^K","^7","^8","^9",1,"^:",null,"^;",95],"~$alias-sym",["^ ","^;",85,"^9",15,"^6","^L","^4","^5","^:",null],"~$name",["^ ","^;",220,"^9",3,"^6","^M","^4","^5","^:",null,"^7",["^2",[["^ ","~:tag","^I","^;",222,"^9",15,"~:end-row",222,"~:end-col",18],["^ ","~:call",["^ ","~:filename","/Users/yogthos/src/jolt/src/jolt/evaluator.janet","^7","^Q","~:lang","~:clj","~:base-lang","^T","~:resolved-ns","^5","^4","^5","^6","^C","~:arity",1],"^;",221,"^9",15,"^O",221,"^P",33]]]],"^R","/Users/yogthos/src/jolt/src/jolt/evaluator.janet","~$macro-fn",["^ ","^1",["^2",[]],"^4","^5","^6","^X","^7","^8","^9",18,"^:",null,"^A",0,"^;",257],"~$kname",["^ ","^;",390,"^9",29,"^6","^Y","^4","^5","^:",null,"^7","^D"],"~$val",["^ ","^;",384,"^9",21,"^6","^Z","^4","^5","^:",null],"~$parse-arg-names",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^[","^7","^8","^9",1,"^:",null,"^G",["^ ","~i1",["^ ","^H",["^ ","^7","~:map","~:val",["^ ","~:fixed",["^ ","^;",202,"^O",668,"^9",11,"^P",13]]],"^J","[args-form]"]],"^;",156],"~$special-symbol?",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^13","^7","^8","^9",1,"^:",null,"^G",["^ ","~i1",["^ ","^H",["^2",["~:boolean"]],"^J","[name]"]],"^;",10],"~$sym-name?",["^ ","^1",["^2",[2]],"^3",true,"^4","^5","^6","^15","^7","^8","^9",1,"^:",null,"^;",6],"~$inner",["^ ","^;",180,"^9",17,"^6","^16","^4","^5","^:",null],"~$saved-ns",["^ ","^;",268,"^9",20,"^6","^17","^4","^5","^:",null],"~$sym-name-str",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^18","^7","^8","^9",1,"^:",null,"^;",70],"~$unwrap-meta-name",["^ ","^1",["^2",[1]],"^3",true,"^4","^5","^6","^19","^7","^8","^9",1,"^:",null,"^;",205]]