[PATCH fennel-ls 1/1] Do not warn on fennel rest in function definition [resolves #10]
Export this patch
From: Tibor Claassen <tc@codebeige.net>
---
src/fennel-ls/compiler.fnl | 5 +++ --
test/diagnostic-test.fnl | 13 ++++++++++++ -
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl
index 1525c3f..ce46cfa 100644
--- a/src/fennel-ls/compiler.fnl
+++ b/src/fennel-ls/compiler.fnl
@@ -183,8 +183,9 @@ later by fennel-ls.language to answer requests from the client."
(where [_fn args] (fennel.sequence? args)) args
(where [_fn _name args] (fennel.sequence? args)) args
_ []))
- (each [_ argument (ipairs args)]
- (define (sym :nil) argument scope))) ;; TODO for now, function arguments are set to nil
+ (each [i argument (ipairs args)]
+ (if (not (and (= i (- (length args) 1)) (sym? argument :&)))
+ (define (sym :nil) argument scope)))) ;; TODO for now, function arguments are set to nil
(λ define-function [ast scope]
;; handle the definitions of a function
diff --git a/test/diagnostic-test.fnl b/test/diagnostic-test.fnl
index 6c39a50..7291768 100644
--- a/test/diagnostic-test.fnl
+++ b/test/diagnostic-test.fnl
@@ -124,8 +124,19 @@
{:message "unused definition: &"}
v))
"not found")
- _ (error "did not match")))))
+ _ (error "did not match"))))
+ (it "does not warn on ampersand in function params"
+ (let [self (create-client)
+ responses (self:open-file! filename "(fn [x & more] (print x more))")]
+ (match responses
+ [{:params {: diagnostics}}]
+ (is.nil (find [_ v (ipairs diagnostics)]
+ (match v
+ {:message "unused definition: &"}
+ v))
+ "not found")
+ _ (error "did not match")))))
--
2.38.5
fennel-ls/patches/.build.yml: SUCCESS in 45s
[Fix #10][0] from [~codebeige][1]
[0]: https://lists.sr.ht/~xerool/fennel-ls/patches/45989
[1]: mailto:tc@codebeige.net
✓ #1081360 SUCCESS fennel-ls/patches/.build.yml https://builds.sr.ht/~xerool/job/1081360