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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect non Expr[..] splice patterns #19944

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Conversation

nicolasstucki
Copy link
Contributor

We compute the pattern using Expr[pt] of the prototype pt of the splice, but this is not enough to reject non-matching patterns. The quoted splices are encoded away before we get to the pattern matching phase where we could potentially detect that they will not match. Instead we check that all quote patterns are Expr[..] when typing the pattern.

Fixes #19941

We compute the pattern using `Expr[pt]` of the prototype `pt` of the splice,
but this is not enough to reject non-matching patterns. The quoted splices
are encoded away before we get to the pattern matching phase where we could
potentially detect that they will not match. Instead we check that all
quote patterns are `Expr[..]` when typing the pattern.

Fixes scala#19941
@nicolasstucki nicolasstucki self-assigned this Mar 14, 2024
@nicolasstucki nicolasstucki changed the title Detect non Exp[..] splice patterns Detect non Expr[..] splice patterns Mar 14, 2024
@nicolasstucki nicolasstucki marked this pull request as ready for review March 14, 2024 11:53
@nicolasstucki nicolasstucki assigned jchyb and unassigned nicolasstucki Mar 14, 2024
Copy link
Contributor

@jchyb jchyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a NIT in the error message, otherwise looks good to me

compiler/src/dotty/tools/dotc/quoted/QuotePatterns.scala Outdated Show resolved Hide resolved
tests/neg-macros/i19941.check Outdated Show resolved Hide resolved
@nicolasstucki nicolasstucki merged commit 96faa3e into scala:main Mar 19, 2024
19 checks passed
@nicolasstucki nicolasstucki deleted the fix-19941 branch March 19, 2024 14:40
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants