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

Out of order var declaration doesn't work with complex expressions #1085

Open
andreypopp opened this issue Jul 28, 2013 · 8 comments
Open

Out of order var declaration doesn't work with complex expressions #1085

andreypopp opened this issue Jul 28, 2013 · 8 comments
Milestone

Comments

@andreypopp
Copy link
Contributor

The following snippet:

a = b * 2
b = 1px
body
  margin a

results in

Error: test.styl:1
 > 1| a = b * 2
   2| b = 1px
   3| body
   4|   margin a

cannot perform b * 2

while

a = b
b = 1px
body
  margin a

compiles well (note the plain a = b instead of a = b * 2 in the first snippet).

@vendethiel
Copy link
Contributor

it should not work at all, imho.

@Panya
Copy link
Member

Panya commented Jul 28, 2013

I'm suppose that you should declare variables before using them (like in other popular languages).

@vendethiel
Copy link
Contributor

This doesn't make any sense. Why would that be allowed?

@kizu
Copy link
Member

kizu commented Jul 28, 2013

I guess, it's somewhat late to fix the current behavior (while someone could find it useful and it could break things for those), but it could be fixed (== the second example shouldn't work too) in 1.0 to make things more consistent and more logical.

@vendethiel
Copy link
Contributor

Thank you.

@andreypopp
Copy link
Contributor Author

@Nami-Doc see referenced issue, I'm trying to convert bootstrap from less to stylus and it seems that bootstrap declares vars out of order which I also find weird. Then I found an inconsistence.

@kizu agreed, it's better to get rid of inconsistent behaviour

@vendethiel
Copy link
Contributor

Bootstrap not making sense certainly is sad, but not worth creating bad behaviors in a language

@kindaro
Copy link

kindaro commented Aug 23, 2015

Stylus is a declarative language. Not imperative. So, order of declarations within the same flat scope should not matter. Because we exile the notion of order of execution. It appears natural and obvious to me.

My 50 cent of example to this discussion:

  9 footer-height = 10vh
...
 24 footer
 25     position absolute
 26     height footer-height
 27     top 100vh - @height

-- Works.

  9 footer-height = 10vh
...
 24 footer
 25     position absolute
 26     top 100vh - @height
 27     height footer-height

-- cannot coerce null to unit

Kindly do consider considering this syntax correct.

@kizu kizu added this to the 1.0 milestone Sep 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants