--- !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 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 - created - "" - - 2014-02-19 18:34:17.036317 Z - sva - 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 - closed with disposition fixed - ""