-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement cycle detection for mixins. #25
Comments
Cycle detection for variables moved to separate issue: #61 |
Cycle detection for mixins is not implemented and the implementation is postponed. Discussion: Mixins can lead into cycles too:
Detecting mixins cycles is harder then detecting variables cycles. Mixins can and do influence the state, so mixin can call itself without being in cycle:
compiles into:
However, very similar less would cycle:
In addition, each mixin has access to all variables defined in its caller, so all caller variables act like additional "hidden parameters":
It is possible to detect cycles in some special situations e.g. if the cycle repeats the same state multiple times, but detecting them in all cases is most likely NP-hard problem. Possible solution would be to detect unusually long mixins chains or measure memory and stop generation prior to stack overflow. We could then make some attempt to detect the cycle and print the most likely candidate. |
Less.js has limited support for this, it was removed from 1.3.3 unit tests file mixins.less. Needs to be added before closing. |
If variables or mixins reference each other in cycle, current version behavior is undefined. That means, that it will crash with stack overflow error.
The text was updated successfully, but these errors were encountered: