laurent.orseau
2020-8-26 11:36:16

Consider the following module (MWE of an issue that has bitten me a couple of times): #lang racket (bad-form #:do 'a #:do 'b) DrRacket (and racket I assume) report the following syntax error: application: duplicate keyword in application in: #:do However, notice that bad-form is itself an unbound identifier. So it could be that adding the correct require would solve the error because bad-form actually allows multiple occurrences of #:do.

Wouldn’t it make sense to report the error about the unbound id before reporting a possible wrong ‘application’?


sorawee
2020-8-26 11:48:32

I know why operationally it’s like that, but you are also right that it’s not ideal


sorawee
2020-8-26 11:49:18

The reason is that before bad-form errors as an unbound-id, it needs to insert the implicit #%top first, and that step is after inserting the implicit #%app.



laurent.orseau
2020-8-26 11:55:16

Thanks. But #%top isn’t responsible for the reported error I assume?


sorawee
2020-8-26 11:55:57

IIRC, no


laurent.orseau
2020-8-26 11:56:43

Also there’s this note: Changed in version 6.3 of package base: Changed the introduction of #%top in a top-level context to unbound identifiers only.


laurent.orseau
2020-8-26 11:57:19

Shouldn’t #%app be responsible for checking whether the id is bound before inferring anything about the form of the call?


sorawee
2020-8-26 11:58:40

laurent.orseau
2020-8-26 12:05:34

Thanks. Can’t make sense of it yet though :slightly_smiling_face:


samth
2020-8-26 14:42:56

@laurent.orseau #%app could do other things with unbound identifiers


laurent.orseau
2020-8-26 14:55:23

I suppose so, but my question is why does it check things like duplicate keyword application when the id is unbound?


laurent.orseau
2020-8-26 14:57:23

Or rather, I think that’s not ideal, and can probably be fixed. But if it takes too much energy or computation time, it may not be worth it


samth
2020-8-26 14:58:00

%app could have an error message that mentioned “maybe it’s because foo is unbound”


laurent.orseau
2020-8-26 15:01:25

Yes, that would certainly help.


samth
2020-8-26 15:04:02

I think that would just be a change in the definition of #%app in racket/private/kw.rkt


laurent.orseau
2020-8-26 15:14:31

This file doesn’t seem to know anything about unbound identifiers though


samth
2020-8-26 16:11:22

You would have to check with identifier-binding


laurent.orseau
2020-8-26 16:12:50

I see, thanks