js-on-sx: reject unary-op directly before ** per spec (parens still allowed)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
This commit is contained in:
@@ -446,14 +446,23 @@
|
||||
(let
|
||||
((e (jp-parse-comma-seq st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
e)))
|
||||
(jp-paren-wrap e))))
|
||||
(do
|
||||
(dict-set! st :idx saved)
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((e (jp-parse-comma-seq st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
e)))))))
|
||||
(jp-paren-wrap e))))))))
|
||||
|
||||
(define
|
||||
jp-paren-wrap
|
||||
(fn
|
||||
(e)
|
||||
(cond
|
||||
((and (list? e) (= (first e) (quote js-unop)))
|
||||
(list (quote js-paren) e))
|
||||
(else e))))
|
||||
|
||||
(define
|
||||
jp-parse-comma-seq
|
||||
@@ -753,6 +762,12 @@
|
||||
(cond
|
||||
((< prec 0) left)
|
||||
((< prec min-prec) left)
|
||||
((and (= op "**") (list? left) (= (first left) (quote js-unop)))
|
||||
(error
|
||||
(str
|
||||
"SyntaxError: Unary operator '"
|
||||
(nth left 1)
|
||||
"' used immediately before exponentiation expression")))
|
||||
(else
|
||||
(do
|
||||
(jp-advance! st)
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
(list (js-sym "js-regex-new") (nth ast 1) (nth ast 2)))
|
||||
((js-tag? ast "js-null") nil)
|
||||
((js-tag? ast "js-undef") (list (js-sym "quote") :js-undefined))
|
||||
((js-tag? ast "js-paren") (js-transpile (nth ast 1)))
|
||||
((js-tag? ast "js-ident") (js-transpile-ident (nth ast 1)))
|
||||
((js-tag? ast "js-unop")
|
||||
(js-transpile-unop (nth ast 1) (nth ast 2)))
|
||||
|
||||
Reference in New Issue
Block a user