I'm currently trying to reuse some syntax classes that I've made, and want to match certain identifiers within them. These syntax classes produce an error if I attempt to import them rather than defining them directly within the macro I am writing. This is a small breaking example I could come up with:
So ~literal matches an identifier -- including a phase as well as a symbol: It's "listat some specific phase level".
In your first example, where the syntax class is defined at phase 1 inside the define-syntax, the list identifier in (~literal list) is the one at phase 1.
But in your second example, where the syntax class is defined at phase 0, the list identifier in (~literal list) is the one at phase 0.
That doesn't match the list at phase 1 in the expansion of test. So the error.
One thing you could do, in your second example, is change (~literal list) to (~literal list #:phase 1).
As in the following. [Note: Just for my own convenience, I changed your two-file example into one file -- with a submodule m playing the role of some-syntax-classes.rkt.]
use ~datum. A bit discouraged, but useful when you only care about
the textual content and don't want to allow it to be renamed (cond
recognizes else by binding, which means it works through renames but
is a bit confusing if else is lexically shadowed).
create, provide, and consistently use your own binding. If you
don't need its value, it can be as simple as (define my-marker #f),
as long as you're consistent about the phasing use as Greg pointed
out.