You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
1.7 KiB

--- !ditz.rubyforge.org,2008-03-06/issue
title: "regexp non-capturing group bug: /(?:a)?/.exec('x') does not match (but should)"
desc: /a?/ matches, so does /(a)?/
type: :bugfix
component: duk
release: v0.10
reporter: sva <sami.vaarala@iki.fi>
status: :closed
disposition: :fixed
creation_time: 2014-02-19 18:32:29.242684 Z
references: []
id: c259c7a979801e1ae101231d116ea8c77f40a98c
log_events:
- - 2014-02-19 18:32:29.617574 Z
- sva <sami.vaarala@iki.fi>
- created
- ""
- - 2014-02-19 18:34:17.036317 Z
- sva <sami.vaarala@iki.fi>
- commented
- |-
Regexp bytecode for /a?/
/a?/
\x00 flags
\x02 nsaved
\x0b save
\x00 index
\x0a sqgreedy
\x00 min
\x01 max
\x01 atomlen
\x06 skip = +3
\x02 char
a 'a'
\x01 match
\x0b save
\x01 match
\x01 match
Regexp bytecode for /(?:a)?/ when compiled with the bug present:
\x00 flags
\x02 nsaved
\x0b save
\x00 index
\x02 char
a 'a'
\x0a sqgreedy
\x00 min
\x01 max
\x01 atomlen
\x02 skip = +1
\x01 match
\x0b save
\x01 index
\x01 match
The bug in the regexp compiler causes the regexp to be essentially
compiled into /a(?:)?/.
After a potential fix, the bytecode is identical to /a?/:
\x00 flags
\x02 nsaved
\x0b save
\x00 0
\x0a sqgreedy
\x00 min
\x01 max
\x01 atomlen
\x06 skip = +3
\x02 char
a 'a'
\x01 match
\x0b save
\x01 index
\x01 match
- - 2014-02-19 22:35:54.814052 Z
- sva <sami.vaarala@iki.fi>
- closed with disposition fixed
- ""