do_test('regular string constant', beer,
'SV = PV\\($ADDR\\) at $ADDR
- REFCNT = 4
+ REFCNT = 5
FLAGS = \\(PADMY,POK,READONLY,pPOK\\)
PV = $ADDR "foamy"\\\0
CUR = 5
do_test('string constant now studied', beer,
'SV = PVMG\\($ADDR\\) at $ADDR
- REFCNT = 5
+ REFCNT = 6
+ FLAGS = \\(PADMY,SMG,POK,READONLY,pPOK,SCREAM\\)
+ IV = 0
+ NV = 0
+ PV = $ADDR "foamy"\\\0
+ CUR = 5
+ LEN = \d+
+ MAGIC = $ADDR
+ MG_VIRTUAL = &PL_vtbl_mglob
+ MG_TYPE = PERL_MAGIC_regex_global\\(g\\)
+');
+
+ is (eval 'index "not too foamy", beer', 8, 'correct index');
+
+ do_test('string constant still studied', beer,
+'SV = PVMG\\($ADDR\\) at $ADDR
+ REFCNT = 6
FLAGS = \\(PADMY,SMG,POK,READONLY,pPOK,SCREAM\\)
IV = 0
NV = 0
PERL_ARGS_ASSERT_FBM_COMPILE;
+ /* Refuse to fbm_compile a studied scalar, as this gives more flexibility in
+ SV flag usage. No real-world code would ever end up using a studied
+ scalar as a compile-time second argument to index, so this isn't a real
+ pessimisation. */
+ if (SvSCREAM(sv))
+ return;
+
if (flags & FBMcf_TAIL) {
MAGIC * const mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL;
sv_catpvs(sv, "\n"); /* Taken into account in fbm_instr() */