Closed Bug 513020 Opened 15 years ago Closed 13 years ago

[Regexp] String.match with global flag does not return null when nothing is found

Categories

(Tamarin Graveyard :: Virtual Machine, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX
Q1 12 - Brannan

People

(Reporter: brbaker, Assigned: pnkfelix)

References

Details

(Whiteboard: has-patch, WE:3073429, WE:3069935)

Attachments

(2 files, 2 obsolete files)

Steps to reproduce: 1. Create a string and a pattern with the global parameter that should NOT match: var line:String = "aaa"; var pattern:RegExp = /bbb/gi; 2. Use String.match: var result = line.match(pattern); 3. Evaluate the result: if(result == null) { trace("Result is null"); } else { trace("Result is not null"); } Actual Results: "Result is not null" Expected Results: "Result is null". The documentation states that "If no match is found, the method returns null. If you pass no value (or an undefined value) as the pattern parameter, the method returns null." The Flex Debugger tells me that <result> is an Array of length 0. It should however be <null>
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Attached file simple testcase (deleted) —
Test should trace out that the "Result is null", but currently the result is NOT null
Transferred from JIRA ASC-3824 http://bugs.adobe.com/jira/browse/ASC-3824 Transferred comments: Brent Baker - [07/31/09 09:02 AM ] String.match() will properly return null when no match is made if the global flag is not enabled. Bug appears to be a problem when no matches made bug global flag is enabled.
Blocks: AS3_Builtins
Flags: flashplayer-qrb? → flashplayer-qrb+
Target Milestone: --- → flash10.1
Assignee: nobody → rreitmai
Priority: -- → P3
Any fix for this bug will likely need version-checking for backwards compatibility.
Flags: in-testsuite?
Flags: flashplayer-needsversioning+
Target Milestone: flash10.1 → Future
Priority: P3 → --
Attached patch allow null array return (obsolete) (deleted) — Splinter Review
Change of behaviour, likely candidate for version check.
Status: NEW → ASSIGNED
Whiteboard: Has patch
Jason, land in TR for Brannan. Note that a SWF version check is required for this change.
Assignee: rreitmai → jason.boyer
Flags: flashplayer-bug+
Priority: -- → P3
Whiteboard: Has patch → has-patch
Target Milestone: Future → Q1 12 - Brannan
Attachment #412517 - Attachment is obsolete: true
Attachment #558890 - Flags: superreview?
Attachment #558890 - Flags: review?(treilly)
Comment on attachment 558890 [details] [diff] [review] Rebased patch and added swf version check. New test case. Please use NULL instead of 0. How does the test harness know to test both branches of the test case?
Attachment #558890 - Flags: review?(treilly) → review+
(In reply to Tommy Reilly from comment #7) > How does the test harness know to test both branches of the test case? If you add a file test/acceptance/as3/RegExp/bug_513020.as.avm_args and it has the following line: USES_SWFVERSION The test harness will then execute the test multiple times using "-swfversion 9 " to "-swfversion 15", take a look at test/acceptance/regress/bug_551587_2.as.avm_args
Attached patch Fixes based on code review (deleted) — Splinter Review
OK, I changed 0 to NULL, and added the .avm_args file so that the test case will run against all versions of SWF that we test.
Attachment #558890 - Attachment is obsolete: true
Attachment #559292 - Flags: superreview?(lhansen)
Attachment #559292 - Flags: review?(treilly)
Attachment #558890 - Flags: superreview?
Attachment #559292 - Flags: superreview?(lhansen) → superreview+
Comment on attachment 559292 [details] [diff] [review] Fixes based on code review +1 prevailing style is to leave off curly braces on one liner if but I'm not a stickler for such things.
Attachment #559292 - Flags: review?(treilly) → review+
Assignee: jason.boyer → fklockii
changeset: 6749:e2cc6403121d user: Jason Boyer <jason.boyer@adobe.com> summary: Bug 513020: allow null array return (author=jason.boyer, r=treilly, sr=lhansen, push=fklockii). http://hg.mozilla.org/tamarin-redux/rev/e2cc6403121d
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Felix, the consensus opinion is that this should be reverted in Brannan and closed as wontfix. It appears this change impacts at least one third party library. paraphrasing: The String.match() behavior that has been in place for 8+ years. Its unlikely we are going to recruit significant #s of new ECMAScript authors over to AS3 development at this time, but we can cause pain to a significant # of our existing AS3 developers via this change. The cost/benefit ratio seems to favor backing this out and never fixing it.
Status: RESOLVED → REOPENED
Priority: P3 → P2
Resolution: FIXED → ---
Okay will revert.
Whiteboard: has-patch → has-patch, WE:3073429, WE:3069935
It seems very strange to me that the JIRA bug (linked in comment 2) seems like it is quoting documentation that sounds like ours but does not match ours. I cannot figure out if our documentation was changed to match the actual behavior of the runtime in the time since the JIRA bug was filed, or if the original filer of the bug did not properly quote our documentation (or perhaps was not quoting our documentation at all). Anyway, like I said, "will revert."
(In reply to Felix S Klock II from comment #14) > I cannot figure out if our documentation was changed to match the actual > behavior of the runtime in the time since the JIRA bug was filed If this is what happened, then we still have a documentation bug, because now the documentation does not match the case of what happens when the 'g' parameter is *not* on the regexp, as Brent noted in comment 2. Concrete illustration at avmshell repl (with JSON stringification so that its crystal clear which cases the array comes up in): avmplus interactive shell Type '?' for help > var line = "aaa" aaa > var patG = /bbb/gi /bbb/gi > var pat1 = /bbb/i /bbb/i > JSON.stringify(line.match(patG)) [] > JSON.stringify(line.match(pat1)) null
changeset: 7137:868c2d2d2e70 user: Felix S Klock II <fklockii@adobe.com> summary: Bug 513020: backout e2cc6403121d reverting its "fix"; setting old behavior in stone (r=fklockii). http://hg.mozilla.org/tamarin-redux/rev/868c2d2d2e70
(the backout removed the test that jason added. it would be good to put in a test for the behavior we are setting in stone.)
Brent, please add a test.
changeset: 7148:8c8106fbe824 user: Brent Baker <brbaker@adobe.com> summary: Bug 513020: add testcase that shows null and empty array being returned during a non-match with with /i and /gi http://hg.mozilla.org/tamarin-redux/rev/8c8106fbe824
Flags: in-testsuite? → in-testsuite+
Status: REOPENED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → FIXED
Resolution: FIXED → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: