@@ -2325,10 +2325,11 @@ public RubyNode visitInterpolatedMatchLastLineNode(Nodes.InterpolatedMatchLastLi
2325
2325
@ Override
2326
2326
public RubyNode visitInterpolatedRegularExpressionNode (Nodes .InterpolatedRegularExpressionNode node ) {
2327
2327
var encodingAndOptions = getRegexpEncodingAndOptions (new Nodes .RegularExpressionFlags (node .flags ));
2328
+ var options = encodingAndOptions .options ;
2328
2329
final ToSNode [] children = translateInterpolatedParts (node .parts );
2329
2330
2330
2331
final RubyEncoding encoding ;
2331
- if (!encodingAndOptions . options .isKcodeDefault ()) { // explicit encoding
2332
+ if (!options .isKcodeDefault ()) { // explicit encoding
2332
2333
encoding = encodingAndOptions .encoding ;
2333
2334
} else {
2334
2335
// use BINARY explicitly probably because forcing encoding isn't implemented yet in Prism
@@ -2341,15 +2342,16 @@ public RubyNode visitInterpolatedRegularExpressionNode(Nodes.InterpolatedRegular
2341
2342
if (child .getValueNode () instanceof StringLiteralNode stringLiteralNode ) {
2342
2343
var fragment = new TStringWithEncoding (stringLiteralNode .getTString (), stringLiteralNode .getEncoding ());
2343
2344
try {
2344
- ClassicRegexp .regexpFragmentCheck (fragment , encodingAndOptions .options , sourceEncoding ,
2345
- currentNode );
2345
+ // MRI: reg_fragment_check
2346
+ var strEnc = ClassicRegexp .setRegexpEncoding (fragment , options , sourceEncoding , currentNode );
2347
+ ClassicRegexp .preprocessCheck (strEnc );
2346
2348
} catch (DeferredRaiseException dre ) {
2347
2349
throw regexpErrorToSyntaxError (dre , node );
2348
2350
}
2349
2351
}
2350
2352
}
2351
2353
2352
- RubyNode rubyNode = new InterpolatedRegexpNode (children , encoding , encodingAndOptions . options );
2354
+ RubyNode rubyNode = new InterpolatedRegexpNode (children , encoding , options );
2353
2355
2354
2356
if (node .isOnce ()) {
2355
2357
rubyNode = new OnceNode (rubyNode );
@@ -2892,17 +2894,17 @@ public RubyNode visitRedoNode(Nodes.RedoNode node) {
2892
2894
public RubyNode visitRegularExpressionNode (Nodes .RegularExpressionNode node ) {
2893
2895
var encodingAndOptions = getRegexpEncodingAndOptions (new Nodes .RegularExpressionFlags (node .flags ));
2894
2896
var encoding = encodingAndOptions .encoding ;
2897
+ var options = encodingAndOptions .options ;
2895
2898
var source = TruffleString .fromByteArrayUncached (node .unescaped , encoding .tencoding , false );
2896
2899
var sourceWithEnc = new TStringWithEncoding (source , encoding );
2897
2900
2898
2901
final RubyRegexp regexp ;
2899
2902
try {
2900
2903
// Needed until https://github.com/ruby/prism/issues/1997 is fixed
2901
- sourceWithEnc = ClassicRegexp .findEncodingForRegexpLiteral (sourceWithEnc , encodingAndOptions .options ,
2902
- sourceEncoding , currentNode );
2904
+ sourceWithEnc = ClassicRegexp .setRegexpEncoding (sourceWithEnc , options , sourceEncoding , currentNode );
2903
2905
2904
2906
regexp = RubyRegexp .create (language , sourceWithEnc .tstring , sourceWithEnc .encoding ,
2905
- encodingAndOptions . options , currentNode );
2907
+ options , currentNode );
2906
2908
} catch (DeferredRaiseException dre ) {
2907
2909
throw regexpErrorToSyntaxError (dre , node );
2908
2910
}
0 commit comments