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

"TypeError: Cannot read property 'start' of null" because of inline JS return statement #2409

Closed
strugee opened this issue Jun 1, 2016 · 4 comments

Comments

@strugee
Copy link

strugee commented Jun 1, 2016

I have the following Jade template (reduced down to a testcase):

- if (object) return;

When compiling this with either jade template.jade or jade --client template.jade, I get:

/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/index.js:115
    return src.slice(node.start, node.end).join('')
                         ^
TypeError: Cannot read property 'start' of null
    at source (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/index.js:115:26)
    at Object.walk.recursive.ReturnStatement (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/index.js:111:41)
    at c (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:82:35)
    at Object.skipThrough (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:180:3)
    at c (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:82:35)
    at Object.base.IfStatement (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:201:3)
    at c (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:82:35)
    at Object.skipThrough (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:180:3)
    at c (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:82:35)
    at Object.base.Program.base.BlockStatement (/usr/local/Cellar/nvm/0.31.1/versions/node/v0.12.14/lib/node_modules/jade/node_modules/with/node_modules/acorn/dist/walk.js:191:5)

I don't want to use Pug since it's still an alpha, so I'm on Jade 1.11.0, running on Node 0.12.14 installed via nvm.

@strugee strugee changed the title "TypeError: Cannot read property 'start' of null" because of inline JS "TypeError: Cannot read property 'start' of null" because of inline JS return statement Jun 1, 2016
@ghost
Copy link

ghost commented Jun 2, 2016

- condtion = false
- result = (condtion === "hohoho" ? "Its hohoho" : "Its not hohoho")

if result
  p.
    #{result}

http://jade-lang.com/reference/case/
http://jade-lang.com/reference/conditionals/
http://jade-lang.com/reference/interpolation/

@TimothyGu
Copy link
Member

@strugee, yep, that looks like a legitimate bug in the with module we are using. I have a patch ready, but I'd like to first bring that module under the governance of @pugjs so we can better maintain that: pugjs/with#11. See also pugjs/with#12 for a patch fixing this issue.

ForbesLindesay pushed a commit to pugjs/with that referenced this issue Jun 3, 2016
@strugee
Copy link
Author

strugee commented Jun 5, 2016

\o/

Thanks, all.

@zhanzhicai2
Copy link

thanks you

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

Successfully merging a pull request may close this issue.

3 participants