drym-org / qi

An embeddable flow-oriented language.
58 stars 12 forks source link

Bad error message on mistakenly providing keyword arguments #135

Closed countvajhula closed 7 months ago

countvajhula commented 8 months ago

We do not support keyword arguments as flow inputs, so while this shouldn't work, the error message should ideally indicate that keyword argument is not supported. Instead:

(~>> (2 1 3 #:key values) (sort <))
; :476:0: ~>>: expected one of these literal symbols: `sep' or `△'
;   at: (sort <)
;   in: (~>> (2 1 3 #:key values) (sort <))
;   Source locations:
;   :476:26

It looks like this is happening because it is trying to match the first (error-catching) clause in the ~>> macro definition, for some reason, and complains that it doesn't match(?):

qi-lib/threading.rkt:
(define-syntax-parser %~>>
  [(_ (arg0 arg ...+) (~or* (~datum sep) (~datum △)) clause:clause ...)
   ;; catch a common usage error
   (report-syntax-error this-syntax
     "(~>> (arg ...) flo ...)"
     "Attempted to separate multiple values."
     "Note that the inputs to ~>> must be wrapped in parentheses.")]
  [(_ args:subject clause:clause ...)
   #:with ags (attribute args.args)
   #'(on ags (~>> clause ...))])

... i.e. it is failing to match on line 2, not the correct second clause on line 8.