Skip to content

Commit

Permalink
Ensure strings created with MVM_string_repeat are in NFG form
Browse files Browse the repository at this point in the history
Check that string a is stable under concatenation with itself before
returning. If it isn't, then run it through re_nfg, similarly to
what we do in MVM_string_concatenate.
  • Loading branch information
samcv committed Aug 23, 2017
1 parent 703b5f5 commit 62f66cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/strings/ops.c
Expand Up @@ -864,7 +864,10 @@ MVMString * MVM_string_repeat(MVMThreadContext *tc, MVMString *a, MVMint64 count
result->body.storage.strands[0].repetitions = count - 1;
result->body.num_strands = 1;
});

/* If string a is not stable under concatenation, we need to create a flat
* string and ensure it is normalized */
if (!MVM_nfg_is_concat_stable(tc, a, a))
result = re_nfg(tc, result);
STRAND_CHECK(tc, result);
return result;
}
Expand Down

0 comments on commit 62f66cb

Please sign in to comment.