@@ -679,27 +679,40 @@ class QRegex::P6Regex::Actions is HLL::Actions {
679
679
my $ node ;
680
680
my $ ord0 ;
681
681
my $ ord1 ;
682
+ sub non_synth_ord ($ chr ) {
683
+ my int $ ord := nqp :: ord ($ chr );
684
+ if nqp :: chr ($ ord ) ne $ chr {
685
+ $/ . CURSOR. panic(" Cannot use $ chr as a range endpoint, as it is not a single codepoint" );
686
+ }
687
+ $ ord
688
+ }
682
689
if $ _ [0 ]<cclass_backslash > {
683
690
$ node := $ _ [0 ]<cclass_backslash >. ast;
684
691
$/ . CURSOR. panic(" Illegal range endpoint in regex: " ~ ~ $ _ )
685
692
if $ node . rxtype ne ' literal' && $ node . rxtype ne ' enumcharlist'
686
693
|| $ node . negate || nqp :: chars ($ node [0 ]) != 1 ;
687
- $ ord0 := $ node . ann(' codepoint' ) // nqp :: ord ($ node [0 ]);
688
- $ ord0 := nqp ::ordbaseat(nqp :: chr ($ ord0 ), 0 ) if $ RXm ;
694
+ $ ord0 := $ node . ann(' codepoint' ) // ($ RXm
695
+ ?? nqp ::ordbaseat($ node [0 ], 0 )
696
+ !! non_synth_ord($ node [0 ]));
689
697
}
690
698
else {
691
- $ ord0 := $ RXm ?? nqp ::ordbaseat(~ $ _ [0 ][0 ], 0 ) !! nqp :: ord (~ $ _ [0 ][0 ]);
699
+ $ ord0 := $ RXm
700
+ ?? nqp ::ordbaseat(~ $ _ [0 ][0 ], 0 )
701
+ !! non_synth_ord(~ $ _ [0 ][0 ]);
692
702
}
693
703
if $ _ [1 ][0 ]<cclass_backslash > {
694
704
$ node := $ _ [1 ][0 ]<cclass_backslash >. ast;
695
705
$/ . CURSOR. panic(" Illegal range endpoint in regex: " ~ ~ $ _ )
696
706
if $ node . rxtype ne ' literal' && $ node . rxtype ne ' enumcharlist'
697
707
|| $ node . negate || nqp :: chars ($ node [0 ]) != 1 ;
698
- $ ord1 := $ node . ann(' codepoint' ) // nqp :: ord ($ node [0 ]);
699
- $ ord1 := nqp ::ordbaseat(nqp :: chr ($ ord1 ), 0 ) if $ RXm ;
708
+ $ ord1 := $ node . ann(' codepoint' ) // ($ RXm
709
+ ?? nqp ::ordbaseat($ node [0 ], 0 )
710
+ !! non_synth_ord($ node [0 ]));
700
711
}
701
712
else {
702
- $ ord1 := $ RXm ?? nqp ::ordbaseat(~ $ _ [1 ][0 ][0 ], 0 ) !! nqp :: ord (~ $ _ [1 ][0 ][0 ]);
713
+ $ ord1 := $ RXm
714
+ ?? nqp ::ordbaseat(~ $ _ [1 ][0 ][0 ], 0 )
715
+ !! non_synth_ord(~ $ _ [1 ][0 ][0 ]);
703
716
}
704
717
$/ . CURSOR. panic(" Illegal reversed character range in regex: " ~ ~ $ _ )
705
718
if $ ord0 > $ ord1 ;
0 commit comments