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

Pass whether a Regexp is a /.../ literal from mruby codegen to Artichoke #2084

Merged
merged 9 commits into from
Aug 14, 2022

Conversation

lopopolo
Copy link
Member

@lopopolo lopopolo commented Aug 14, 2022

With these changes:

$ cargo run --bin airb -q
artichoke 0.1.0-pre.0 (2022-08-11 revision 6046) [x86_64-apple-darwin]
[rustc 1.63.0 (4b91a6ea7 2022-08-08) on x86_64-apple-darwin]
>>> /airb/in

[artichoke-backend/src/extn/core/regexp/enc.rs:13] encoding = [
    110,
]
[artichoke-backend/src/extn/core/regexp/opts.rs:18] options = [
    105,
    108,
]
[artichoke-backend/src/extn/core/regexp/trampoline.rs:22] options = Some(
    Options {
        flags: IGNORECASE | LITERAL,
    },
)
=> /airb/in

And the exceptions:

$ cargo run --bin airb -q
artichoke 0.1.0-pre.0 (2022-08-11 revision 6046) [x86_64-apple-darwin]
[rustc 1.63.0 (4b91a6ea7 2022-08-08) on x86_64-apple-darwin]
>>> /abc/in
=> /abc/in
>>> /abc/in.send(:initialize, "xyz")
Traceback (most recent call last):
        2: from (airb):2
        1: from (airb):2:in initialize
SecurityError (can't modify literal regexp)
>>> Regexp.compile('jkl')
=> /jkl/
>>> Regexp.compile('jkl').send(:initialize, "qwerty")
Traceback (most recent call last):
        2: from (airb):4
        1: from (airb):4:in initialize
TypeError (already initialized regexp)

mruby codegen pushes a block to `Regexp::compile`.
This is an in-channel signal from the mruby VM that the regexp was parsed
as a literal. See parse.y.
Required to pass specs and not emit spurious warnings.

This is a breaking change to spinoso-regexp because it makes a previously
const function non-const.
@lopopolo lopopolo added A-parser Area: Parser implementations. A-codegen Area: Code generation while executing Ruby. B-mruby Backend: Implementation of artichoke-core using mruby. C-bug Category: This is a bug. labels Aug 14, 2022
@lopopolo
Copy link
Member Author

@lopopolo
Copy link
Member Author

Tracking the upstreaming to artichoke/mruby the parser and codegen changes from aab134d here:

@lopopolo lopopolo merged commit 8e9e07d into trunk Aug 14, 2022
@lopopolo lopopolo deleted the lopopolo/regexp-literal branch August 14, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation while executing Ruby. A-parser Area: Parser implementations. B-mruby Backend: Implementation of artichoke-core using mruby. C-bug Category: This is a bug.
Development

Successfully merging this pull request may close these issues.

None yet

1 participant