stylus: ParseError: expected "indent", got "outdent" (using hashes)

The following Stylus fails when not using a colon after background-color but works with one:

Failure

$Colors = {'Red': #ff0000}

body
    background-color $Colors.Red
> stylus < test.styl 

/usr/local/lib/node_modules/stylus/bin/stylus:494
      if (err) throw err;
                     ^
ParseError: stdin:4
   1| $Colors = {'Red': #ff0000}
   2| 
   3| body
 > 4|     background-color $Colors.Red
   5| 

expected "indent", got "outdent"

    at Parser.error (/usr/local/lib/node_modules/stylus/lib/parser.js:179:11)
    at Parser.expect (/usr/local/lib/node_modules/stylus/lib/parser.js:207:12)
    at Parser.block (/usr/local/lib/node_modules/stylus/lib/parser.js:688:12)
    at Parser.selector (/usr/local/lib/node_modules/stylus/lib/parser.js:1224:24)
    at Parser.property (/usr/local/lib/node_modules/stylus/lib/parser.js:1175:47)
    at Parser.ident (/usr/local/lib/node_modules/stylus/lib/parser.js:1130:25)
    at Parser.stmt (/usr/local/lib/node_modules/stylus/lib/parser.js:632:26)
    at Parser.statement (/usr/local/lib/node_modules/stylus/lib/parser.js:540:21)
    at Parser.block (/usr/local/lib/node_modules/stylus/lib/parser.js:700:21)
    at Parser.selector (/usr/local/lib/node_modules/stylus/lib/parser.js:1224:24)

Success

$Colors = {'Red': #ff0000}

body
    background-color: $Colors.Red
> stylus < test.styl 
body {
  background-color: #f00;
}

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 2
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

guys, missing the obvious… you could go the array notation route, works just fine

body = { p: 'foo' }

html
  prop  body['p']    <-- use array, no colon

i just run into the same problem. maybe the documentation on the hashes should be extended.

Couldn’t this be disambiguated if there was something following some body.p as it then could not be a nested selector:

body = { p: 'foo' }

html
  some body.p
  // ^^^^^^^^ cannot be nested selector since there are no
  // rules for it, considering next line is not indented…
  other #ff0000