fix "unknown module field" when accessing fields from doc objects with no known fields
this means stuff like `io.stderr:write` isn't a warning anymore
This commit is contained in:
parent
07e8239216
commit
3d1485060c
@ -65,14 +65,16 @@ 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 [server document stack opts]
|
(λ search-document [server document stack opts]
|
||||||
(when (and (not= (tostring (?. document :binding)) :_G)
|
(when (not= (tostring (?. document :binding)) :_G)
|
||||||
(= (length stack) 1))
|
|
||||||
(set opts.searched-through-require-with-stack-size-1 true))
|
(set opts.searched-through-require-with-stack-size-1 true))
|
||||||
(if (= 0 (length stack))
|
(if (= 0 (length stack))
|
||||||
document
|
document
|
||||||
(and document.fields
|
(and document.fields
|
||||||
(. document.fields (. stack (length stack))))
|
(. document.fields (. stack (length stack))))
|
||||||
(search-document server (. document.fields (table.remove stack)) stack opts)))
|
(search-document server (. document.fields (table.remove stack)) stack opts)
|
||||||
|
(not document.fields)
|
||||||
|
(do
|
||||||
|
(set opts.searched-through-require-indeterminate true))))
|
||||||
|
|
||||||
(λ search-val [server file ?ast stack opts]
|
(λ search-val [server file ?ast stack opts]
|
||||||
"searches for the definition of the ast, adjusted to 1 value"
|
"searches for the definition of the ast, adjusted to 1 value"
|
||||||
|
|||||||
@ -46,7 +46,9 @@ the `file.diagnostics` field, filling it with diagnostics."
|
|||||||
"if ?ast is a module field that isn't known, return a diagnostic"
|
"if ?ast is a module field that isn't known, return a diagnostic"
|
||||||
(let [opts {}
|
(let [opts {}
|
||||||
item (analyzer.search-ast server file ?ast stack opts)]
|
item (analyzer.search-ast server file ?ast stack opts)]
|
||||||
(if (and (not item) opts.searched-through-require-with-stack-size-1)
|
(if (and (not item)
|
||||||
|
opts.searched-through-require-with-stack-size-1
|
||||||
|
(not opts.searched-through-require-indeterminate))
|
||||||
{:range (message.ast->range server file symbol)
|
{:range (message.ast->range server file symbol)
|
||||||
:message (.. "unknown field: " (tostring symbol))
|
:message (.. "unknown field: " (tostring symbol))
|
||||||
:severity message.severity.WARN
|
:severity message.severity.WARN
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
(case (os.getenv "FAITH_TEST")
|
(case (os.getenv "FAITH_TEST")
|
||||||
target (let [(module function) (target:match "([^ ]+) ([^ ]+)")]
|
target (let [(module function) (target:match "([^ ]+) ([^ ]+)")]
|
||||||
(xpcall (. (require module) function) #(print ($:tostring target))))
|
(tset package.loaded module {function (. (require module) function)})
|
||||||
|
(faith.run [module]))
|
||||||
_ (faith.run
|
_ (faith.run
|
||||||
[:test.json-rpc
|
[:test.json-rpc
|
||||||
:test.string-processing
|
:test.string-processing
|
||||||
|
|||||||
@ -110,6 +110,9 @@
|
|||||||
field.unknown"}
|
field.unknown"}
|
||||||
[]
|
[]
|
||||||
[{:code 302}])
|
[{:code 302}])
|
||||||
|
(check "package.loaded.mymodule io.stderr.write"
|
||||||
|
[]
|
||||||
|
[{:code 302}])
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(fn test-unnecessary-colon []
|
(fn test-unnecessary-colon []
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user