Don't assume newfile is nonnil before using it.

This commit is contained in:
Phil Hagelberg 2022-09-08 09:30:53 -07:00 committed by XeroOl
parent 06a6e8c7ea
commit 783b1858b2
No known key found for this signature in database
GPG Key ID: 9DD4B4B4DAED0322

View File

@ -55,11 +55,11 @@ the data provided by compiler.fnl."
(λ search-list [self file call stack opts]
(match call
[-require- mod]
(let [newfile (state.get-by-module self mod)
newitem (. newfile.ast (length newfile.ast))]
(if newfile
(search self newfile newitem stack opts)))
; A . form indexes into item 1 with the other items
(let [newfile (state.get-by-module self mod)]
(when newfile
(let [newitem (. newfile.ast (length newfile.ast))]
(search self newfile newitem stack opts))))
;; A . form indexes into item 1 with the other items
[-dot- & split]
(search self file (. split 1)
(fcollect [i (length split) 2 -1 &into stack]