Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved error messages for special forms #1147

Merged
merged 1 commit into from
May 21, 2023

Conversation

zevv
Copy link
Contributor

@zevv zevv commented May 21, 2023

This patch improves the error messages for special forms somewhat.

Below is a list with the wrong code, the old error message and the new error message:

(defn test [body msg_old msg_new]                                                                                      
  (def msg (try (eval body) ([err fib] err)))
  (if-not (= msg msg_old) (pp [body msg])))

(def foo @[1 2 3])

(test '(while true)    "expected at least 2 arguments"                                                                             
                       "expected at least 2 arguments to while")

(test '(var alice)     "expected at least 2 arguments"                                                                           
                       "expected at least 2 arguments to var") 

(test '(def bob)       "expected at least 2 arguments"                                                                           
                       "expected at least 2 arguments to def")

(test '(defn foo)      "(macro) expected integer key in range [0, 0), got 0"                                                                              
                       "(macro) expected integer key for tuple in range [0, 0), got 0")

(test '(set)           "expected 2 arguments"                                                                           
                       "expected 2 arguments to set")

(test '(set a)         "expected 2 arguments"                                                                           
                       "expected 2 arguments to set")

(test '(set (foo 5) 1) "expected 2 arguments"                                                                           
                       "expected 2 arguments to set") 

@bakpakin bakpakin merged commit cc55452 into janet-lang:master May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants