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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow type with more than one generic arg #47

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

MiSawa
Copy link
Contributor

@MiSawa MiSawa commented Apr 15, 2024

I noticed that we can't use generic types with two or more arguments for the @kind part of the input! macro.
This is, IIUC, bacause the comma , that separates generic arguments is treated as a comma that separates fields in input! macro, and thus read_value! gets something like @kind Foo<Arg1 .

To fix the issue, I had to special-case vec type [...] and tuple type (...) inside the input! macro and fall-through to ty instead of tt*, since once the whole [...]/(..) are matched to ty it can't be matched to [ tt* ] / ( tt* ) in read_value! macro, it seems to me. (see: https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment )

Disclaimer: I'm noob at macros, and not 100% confident with the change. Please read the change with a skeptical eye 馃檹

@statiolake
Copy link
Owner

Sorry for the late reply. It looks good to me.
As far as I remember, the only reason I avoided using ty matcher is to specialize vectors [T; n] and tuples (T, U, ...), just as you explained. They seem to be correctly cared in the fix.

CI is failing but that's not related to this PR. I'll merge this and fix it later.

Thank you for the PR!

@statiolake statiolake merged commit cb981b9 into statiolake:master Apr 29, 2024
11 of 16 checks passed
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.

None yet

2 participants