Fix unknown field false positive
When attempting to search through a require, analyzer.search-list was returning nil instead of indeterminate if it could not find the file. Fixes #89
This commit is contained in:
parent
b08743f79e
commit
515e40bd4c
@ -139,15 +139,16 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
|
||||
(search-multival server file (. call (+ len 1)) stack (+ multival (- len) 1) opts)))
|
||||
(where (or :require :include))
|
||||
(let [mod (. call 2)]
|
||||
(if (= multival 1)
|
||||
(when (= :string (type mod))
|
||||
(let [newfile (files.get-by-module server mod file.macro-file?)]
|
||||
(when newfile
|
||||
(compiler.compile server newfile)
|
||||
(let [newitem (. newfile.ast (length newfile.ast))]
|
||||
(when (= (length stack) 1)
|
||||
(set opts.searched-through-require-with-stack-size-1 true))
|
||||
(search-val server newfile newitem stack opts)))))))
|
||||
(when (and (= multival 1) (= :string (type mod)))
|
||||
(when (= (length stack) 1)
|
||||
(set opts.searched-through-require-with-stack-size-1 true))
|
||||
(case (files.get-by-module server mod file.macro-file?)
|
||||
newfile (do
|
||||
(compiler.compile server newfile)
|
||||
(let [newitem (. newfile.ast (length newfile.ast))]
|
||||
(search-val server newfile newitem stack opts)))
|
||||
_ (if opts.searched-through-require-with-stack-size-1
|
||||
{:indeterminate true}))))
|
||||
"."
|
||||
(if (= multival 1)
|
||||
(let [[_ & rest] call]
|
||||
|
||||
@ -435,6 +435,15 @@
|
||||
(where (or a [a])) (print (+ a 3))
|
||||
(catch (x) x))))
|
||||
|
||||
(fn test-re-export-module []
|
||||
(check {:utils.fnl
|
||||
"{:mod (require :module)}"
|
||||
:main.fnl
|
||||
"(local {: mod} (require :utils))"}
|
||||
[]
|
||||
[{:code :unknown-module-field :message "unknown field: mod"}])
|
||||
nil)
|
||||
|
||||
{: test-unused
|
||||
: test-ampersand
|
||||
: test-unknown-module-field
|
||||
@ -454,4 +463,5 @@
|
||||
: test-duplicate-keys
|
||||
: test-nested-associative-operator
|
||||
: test-zero-indexed
|
||||
: test-legacy-multival}
|
||||
: test-legacy-multival
|
||||
: test-re-export-module}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user