[racket-dev] syntax-parse ~once keyword sometimes does not report too-few error?

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Thu Jul 25 23:13:28 EDT 2013

Wait, why two bugs? Won't fixing the second thing you mentioned also
fix the first? I guessed that multiple error messages were getting
merged but the wrong one was chosen. Is that not what is happening?

On Thu, Jul 25, 2013 at 9:10 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:
> On 07/25/2013 05:41 PM, Stephen Chang wrote:
>>
>> Here is a syntax-parse macro that requires one subexpression to be
>> wrapped with an exclamation point.
>>
>> (define-syntax (test stx)
>>      (syntax-parse stx #:datum-literals (!)
>>        [((~or (~once (! x:expr) #:name "!")
>>               (~not (! y:expr))) ...)
>>         #'42]))
>>
>> Everything works like I would expect:
>>
>> (test (! 1) (! 2)) => test: too many occurrences of ! in: ()
>> (test (! 1) 2) => 42
>> (test 1 2) => test: missing required occurrence of ! in: ()
>>
>>
>> Here is the same macro but with an extra ~seq and an extra pair of
>> parens around the pattern:
>>
>> (define-syntax (test stx)
>>    (syntax-parse stx #:datum-literals (!)
>>      [((~seq (~or (~once (! x:expr) #:name "!")
>>                   (~not (! y:expr))) ...))
>>       #'42]))
>>
>> Here are the same tests:
>>
>> (test (! 1) (! 2)) => test: too many occurrences of ! in: ()
>> (test (! 1) 2) => 42
>> (test 1 2) => test: bad syntax in: (test 1 2)
>>
>> I expected the same outputs as the first macro, but the last test
>> example only reports "bad syntax" and not "too few". Is this expected
>> behavior that I'm not understanding or a bug?
>
>
> That's a bug. Two bugs, actually: your two examples should behave the same,
> and "too-few" failures should be ranked higher. I'm working on a fix.
>
> Ryan
>

Posted on the dev mailing list.