Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'match' of undefined #43

Open
jcubic opened this issue May 7, 2019 · 3 comments
Open

Cannot read property 'match' of undefined #43

jcubic opened this issue May 7, 2019 · 3 comments

Comments

@jcubic
Copy link

jcubic commented May 7, 2019

I've tried to transpile my S-Expression parser to php

But got this error:

/mnt/ssd/projects/jcubic/lip/node_modules/js2php/core/string.js:119
    var regexpData = args[0].raw.match(/^\/([^\/]+)\/([gimy])?$/),
                                 ^

TypeError: Cannot read property 'match' of undefined
    at split (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/core/string.js:119:34)
    at Object.evaluate (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/core.js:26:18)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:235:26)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:196:20)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:269:21)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:196:20)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:269:21)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:196:20)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:182:24)
    at visit (/mnt/ssd/projects/jcubic/lip/node_modules/js2php/index.js:52:20)

It may be because of this:

var re = new RegExp("((^|[^\\\\])(?:\\\\\\\\)*)" + quote, "g");

in my code I'm parsing multiline string that may have escaped quotes.

@jcubic
Copy link
Author

jcubic commented May 7, 2019

This also may be because of my regex for regexes:

var re_re = /^\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;

Your regex is quite fragile you can't have escaped \/ inside regex literal.

@endel
Copy link
Owner

endel commented May 7, 2019

@jcubic can you check this pull-request? there are a bunch of additions I haven't tested yet. maybe your case has been fixed here: #42

@NesCafe62
Copy link

when I tried some code on demo page I also got

Uncaught TypeError: (intermediate value).match is not a function

I narrowed down the line which causes it, it is:

y = i[+1];

I tried with different variable names. but seems that index [1] causing this. when I changed to y = i[0+1]; or y = i[+1]; it started working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants