[CLJS-471] Empty regexp causes Closure Compiler error Created: 13/Feb/13 Updated: 25/Apr/13 |
|
| Status: | Open |
| Project: | ClojureScript |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Trivial |
| Reporter: | Bodil Stokke | Assignee: | Michał Marczyk |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
An empty regexp of the form #"" compiles to //, which is not an empty regexp but a comment, causing the code following the supposed regexp on the affected line to be commented out. This tends to cause compiler errors when Closure Compiler tries to parse it. #"" should instead produce either /(?:)/ or new RegExp(""). |
| Comments |
| Comment by Michał Marczyk [ 06/Apr/13 6:50 PM ] |
|
Commit message: CLJS-471: prevent empty regexps from causing compiler errors
This patch chooses to emit
(new RegExp(""))
rather than
/(?:)/
so that (pr-str #"") returns
"#\"\""
rather than
"#\"(?:)\""
A test for the above is included.
|
| Comment by David Nolen [ 24/Apr/13 9:52 PM ] |
|
I tried applying this in master, the included test fails. |
| Comment by Michał Marczyk [ 25/Apr/13 5:57 AM ] |
|
Thanks for letting me know. I've checked the value of new RegExp("").source in a Node.js REPL (0.10.3) and it turns out to be '(? |