Unknown field errors in _G are suppressed

This commit is contained in:
XeroOl 2024-05-12 12:25:14 -05:00
parent 31c22fe261
commit be44cda696
2 changed files with 13 additions and 6 deletions

View File

@ -65,7 +65,8 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
(stack-add-split! stack (utils.multi-sym-split symbol))) (stack-add-split! stack (utils.multi-sym-split symbol)))
(λ search-document [self document stack opts] (λ search-document [self document stack opts]
(doto opts (tset :searched-through-require true)) (when (not= (tostring (?. document :binding)) :_G)
(set opts.searched-through-require true))
(if (= 0 (length stack)) (if (= 0 (length stack))
document document
(and document.fields (and document.fields

View File

@ -87,11 +87,17 @@
:main.fnl :main.fnl
"(local {: a : c &as guy} (require :the-guy-they-tell-you-not-to-worry-about)) "(local {: a : c &as guy} (require :the-guy-they-tell-you-not-to-worry-about))
(print guy.b guy.d)"} (print guy.b guy.d)"}
[{:code 302}] [{:code 302 :message "unknown module field: a"} [{:code 302 :message "unknown field: guy.d"}]
{:code 302 :message "unknown module field: b"}]) [{:code 302 :message "unknown field: a"}
(check "table.insert2" {:code 302 :message "unknown field: b"}])
[{:code 302}] (check "table.insert2 table.insert"
[])) [{:code 302 :message "unknown field: table.insert2"}]
[{:code 302 :message "unknown field: table.insert"}])
;; if you explicitly write "_G", it should turn off this test. Hardcoded.
(check "_G.insert2"
[]
[{:code 302}])
nil)
(fn test-unnecessary-colon [] (fn test-unnecessary-colon []
(check "(let [x :haha] (: x :find :a))" (check "(let [x :haha] (: x :find :a))"