Skip to content

Fix parseFlags to handle constant-folded flag values#61

Merged
danslapman merged 1 commit intoleviysoft:mainfrom
mbovel:fix-constant-folded-flags
Apr 9, 2026
Merged

Fix parseFlags to handle constant-folded flag values#61
danslapman merged 1 commit intoleviysoft:mainfrom
mbovel:fix-constant-folded-flags

Conversation

@mbovel
Copy link
Copy Markdown
Contributor

@mbovel mbovel commented Apr 8, 2026

Problem

If the compiler constant-folds a flags expression (e.g. Pattern.CASE_INSENSITIVE | Pattern.COMMENTS) into a single IntConstant (e.g. 6), parseFlag failed to match.

Solution

This PR adds a case to decompose the constant back into individual flag bits.

Notes

This issue was found while enhancing constant-folding in the Scala 3 compiler:

Checklist

  • Unit test all changes
  • Update README.md if applicable
  • Add [WIP] to the pull request title if it's work in progress
  • Squash commits that aren't meaningful changes

@oolong/maintainers

@danslapman danslapman force-pushed the fix-constant-folded-flags branch 2 times, most recently from ec49f2a to b697afa Compare April 9, 2026 07:12
When the compiler constant-folds `Pattern.CASE_INSENSITIVE | Pattern.COMMENTS`
into a single IntConstant (e.g. 6), parseFlags failed to match. This adds a
case to decompose the constant back into individual flag bits.

See scala/scala3#25731

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@danslapman danslapman force-pushed the fix-constant-folded-flags branch from b697afa to 8bf6cae Compare April 9, 2026 07:28
@danslapman danslapman added the bug Something isn't working label Apr 9, 2026
@danslapman danslapman merged commit 5bb5fb9 into leviysoft:main Apr 9, 2026
3 checks passed
@danslapman
Copy link
Copy Markdown
Member

Thank you for your contribution @mbovel!

@mbovel mbovel deleted the fix-constant-folded-flags branch April 9, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants