kwargs test failed
eight04 opened this issue · 4 comments
stylus-lang
inspects the source code of the function to get function argument names:
https://github.com/openstyles/stylus-lang/blob/c3f044a7b8864260aa5a3cd88fa5508ed0fc5339/lib/visitor/evaluator.js#L1033
https://github.com/openstyles/stylus-lang/blob/c3f044a7b8864260aa5a3cd88fa5508ed0fc5339/lib/utils.js#L375-L379
This method doesn't work if we enable variable name mangling in terser compressor. Here are some solutions:
- Disable mangling completely. This is not ideal because, in order to dedup variable names during scope hoisting, rollup needs to suffix those variable names with some random numbers leading to longer variable names.
- Make terser support
mangle.keep_fargs
so function arguments won't be mangled. - We don't care. Let's just wait for someone opening an issue about named parameters and tell them that it is a known issue.
Stack trace
stylus renderer
1) kwargs
0 passing (98ms)
1 failing
1) stylus renderer
kwargs:
Error: stylus:42:30
38| #login {
39| foo: operate('/', 2, 10);
40| foo: operate('/', 10, 2);
41|
42| foo: operate(op: '/', 10, 2);
------------------------------------^
43| foo: operate(10, op: '/', 2);
44| foo: operate(10, 2, op: '/');
45|
TypeError: expected "op" to be a string, but got unit:10
at "#login " (stylus:37:2)
at R (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:22426)
at Evaluator.operate (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:45595)
at Evaluator.Qt.invokeBuiltin (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:66960)
at Evaluator.Qt.visitCall (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:60943)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.visitExpression (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:62299)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.visitProperty (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:62669)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.visitBlock (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:63237)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.visitGroup (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:57860)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.visitRoot (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:63074)
at Evaluator.g.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:10511)
at Evaluator.Qt.visit (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:56800)
at Evaluator.Qt.evaluate (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:57689)
at Renderer.render (eval at <anonymous> (test\test.js:7:1), <anonymous>:1:147469)
at Context.<anonymous> (test\test.js:29:47)
No. 3 sounds bad so it's 1 or 2, I guess.
Or 4, fix stylus-lang
so it doesn't depend on fn.toString()
. Since this only affect built-in functions, we just have to fix these js files:
https://github.com/openstyles/stylus-lang/tree/stylus-extension/lib/functions
Fixed at openstyles/stylus-lang#5