Skip to content

Conversation

jfhamlin
Copy link
Contributor

Add support for *regexp.Regexp values in code generator by serializing them as regexp.MustCompile() calls. The regex pattern string is preserved using the Regexp.String() method.

This fixes the "unsupported value type *regexp.Regexp" error when using regex literals (#"...") in AOT-compiled code. The re-pattern function already worked because it returns the compiled regexp at runtime rather than embedding it as a constant.

Fixes #132

Add support for *regexp.Regexp values in code generator by serializing
them as regexp.MustCompile() calls. The regex pattern string is preserved
using the Regexp.String() method.

This fixes the "unsupported value type *regexp.Regexp" error when using
regex literals (#"...") in AOT-compiled code. The re-pattern function
already worked because it returns the compiled regexp at runtime rather
than embedding it as a constant.

Added comprehensive test cases covering various regex patterns including
special characters, escapes, quotes, and newlines.
@jfhamlin jfhamlin merged commit 6f3ed05 into main Oct 11, 2025
2 checks passed
@jfhamlin jfhamlin deleted the fix/regex-literal-aot branch October 11, 2025 19:42
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.

AOT: unsupported value type *regexp.Regexp

1 participant