@@ -9884,6 +9884,7 @@ parse_qmark(struct parser_params *p, int space_seen)
98849884 rb_encoding *enc;
98859885 register int c;
98869886 VALUE lit;
9887+ const char *start = p->lex.pcur;
98879888
98889889 if (IS_END()) {
98899890 SET_LEX_STATE(EXPR_VALUE);
@@ -9908,13 +9909,11 @@ parse_qmark(struct parser_params *p, int space_seen)
99089909 }
99099910 newtok(p);
99109911 enc = p->enc;
9911- if (!parser_isascii(p)) {
9912- if (tokadd_mbchar(p, c) == -1) return 0;
9913- }
9914- else if ((rb_enc_isalnum(c, p->enc) || c == '_') &&
9915- !lex_eol_p(p) && is_identchar(p, p->lex.pcur, p->lex.pend, p->enc)) {
9912+ int w = parser_precise_mbclen(p, start);
9913+ if (is_identchar(p, start, p->lex.pend, p->enc) &&
9914+ !(lex_eol_ptr_n_p(p, start, w) || !is_identchar(p, start + w, p->lex.pend, p->enc))) {
99169915 if (space_seen) {
9917- const char *start = p->lex.pcur - 1, * ptr = start;
9916+ const char *ptr = start;
99189917 do {
99199918 int n = parser_precise_mbclen(p, ptr);
99209919 if (n < 0) return -1;
@@ -9942,7 +9941,7 @@ parse_qmark(struct parser_params *p, int space_seen)
99429941 }
99439942 }
99449943 else {
9945- tokadd( p, c);
9944+ if (tokadd_mbchar( p, c) == -1) return 0 ;
99469945 }
99479946 tokfix(p);
99489947 lit = STR_NEW3(tok(p), toklen(p), enc, 0);
0 commit comments