HS: mixed-op enforcement + short-circuit + typecheck + strings (+7 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 10m43s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 10m43s
- parser.sx: parse-logical now rejects mixed and/or without parens
- parser.sx: parse-arith now rejects mixed +/-/* //%/mod without parens
- generate-sx-tests.py: MANUAL_TEST_BODIES for short-circuit and/or,
typecheck (direct hs-type-assert calls), template string test
- generate-sx-tests.py: Pattern 5 for error("expr") -> assert-throws
- hs-run-filtered.js: redefine try-call to _run-test-thunk after loading
so assert-throws actually catches exceptions (was always {ok true})
- hs-run-filtered.js: clear __hs_deadline immediately after test eval
to prevent cascading timeout fires in result inspection K.eval calls
- hs-run-filtered.js: typecheck suite in _NO_STEP_LIMIT_SUITES and
_SLOW_DEADLINE_SUITES (hs-type-assert JIT is slow on first call)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -71,12 +71,14 @@
|
||||
((typ (tp-type)) (val (tp-val)))
|
||||
(cond
|
||||
((or (= typ "ident") (= typ "keyword"))
|
||||
(do (adv!) (parse-prop-chain (list (quote .) owner val))))
|
||||
(do
|
||||
(adv!)
|
||||
(parse-prop-chain (list (quote poss) owner val))))
|
||||
((= typ "attr") (do (adv!) (list (quote attr) val owner)))
|
||||
((= typ "class")
|
||||
(let
|
||||
((prop (get (adv!) "value")))
|
||||
(parse-prop-chain (list (quote .) owner prop))))
|
||||
(parse-prop-chain (list (quote poss) owner prop))))
|
||||
((= typ "style") (do (adv!) (list (quote style) val owner)))
|
||||
(true owner)))))
|
||||
(define
|
||||
@@ -116,7 +118,18 @@
|
||||
(prev-end)
|
||||
base-line
|
||||
{:root base})))
|
||||
base)))))
|
||||
(if
|
||||
(and
|
||||
(= (tp-type) "op")
|
||||
(= (tp-val) "'s")
|
||||
(not (at-end?)))
|
||||
(let
|
||||
((poss-prop (begin (adv!) (tp-val))))
|
||||
(do
|
||||
(adv!)
|
||||
(parse-prop-chain
|
||||
(list (make-symbol "poss") base poss-prop))))
|
||||
base))))))
|
||||
(define
|
||||
parse-trav
|
||||
(fn
|
||||
@@ -429,8 +442,7 @@
|
||||
(let
|
||||
((name val) (args (parse-call-args)))
|
||||
(cons (quote call) (cons (list (quote ref) name) args)))))
|
||||
((= typ "keyword")
|
||||
(do (adv!) (list (quote ref) val)))
|
||||
((= typ "keyword") (do (adv!) (list (quote ref) val)))
|
||||
(true nil)))))
|
||||
(define
|
||||
parse-poss
|
||||
@@ -443,10 +455,13 @@
|
||||
((= (tp-type) "dot")
|
||||
(do
|
||||
(adv!)
|
||||
(let ((typ2 (tp-type)) (val2 (tp-val)))
|
||||
(let
|
||||
((typ2 (tp-type)) (val2 (tp-val)))
|
||||
(if
|
||||
(or (= typ2 "ident") (= typ2 "keyword"))
|
||||
(do (adv!) (parse-poss (list (make-symbol ".") obj val2)))
|
||||
(do
|
||||
(adv!)
|
||||
(parse-poss (list (make-symbol ".") obj val2)))
|
||||
obj))))
|
||||
((= (tp-type) "paren-open")
|
||||
(let
|
||||
@@ -916,13 +931,29 @@
|
||||
(left)
|
||||
(cond
|
||||
((match-kw "and")
|
||||
(let
|
||||
((right (parse-collection (parse-cmp (parse-arith (parse-poss (parse-atom)))))))
|
||||
(parse-logical (list (quote and) left right))))
|
||||
(do
|
||||
(when
|
||||
(and
|
||||
(list? left)
|
||||
(> (len left) 0)
|
||||
(= (first left) (quote or)))
|
||||
(error
|
||||
"You must parenthesize logical operations with different operators"))
|
||||
(let
|
||||
((right (parse-collection (parse-cmp (parse-arith (parse-poss (parse-atom)))))))
|
||||
(parse-logical (list (quote and) left right)))))
|
||||
((match-kw "or")
|
||||
(let
|
||||
((right (parse-collection (parse-cmp (parse-arith (parse-poss (parse-atom)))))))
|
||||
(parse-logical (list (quote or) left right))))
|
||||
(do
|
||||
(when
|
||||
(and
|
||||
(list? left)
|
||||
(> (len left) 0)
|
||||
(= (first left) (quote and)))
|
||||
(error
|
||||
"You must parenthesize logical operations with different operators"))
|
||||
(let
|
||||
((right (parse-collection (parse-cmp (parse-arith (parse-poss (parse-atom)))))))
|
||||
(parse-logical (list (quote or) left right)))))
|
||||
(true left))))
|
||||
(define
|
||||
parse-expr
|
||||
@@ -1475,7 +1506,8 @@
|
||||
((match-kw "to")
|
||||
(let
|
||||
((value (parse-expr)))
|
||||
(if (and (list? tgt) (= (first tgt) (quote query)))
|
||||
(if
|
||||
(and (list? tgt) (= (first tgt) (quote query)))
|
||||
(list (quote set-el!) tgt value)
|
||||
(list (quote set!) tgt value))))
|
||||
((match-kw "on")
|
||||
@@ -2140,6 +2172,27 @@
|
||||
(= val "%")))
|
||||
(and (= typ "keyword") (= val "mod")))
|
||||
(do
|
||||
(when
|
||||
(and (list? left) (> (len left) 0))
|
||||
(let
|
||||
((left-op (first left)))
|
||||
(when
|
||||
(or
|
||||
(and
|
||||
(or (= left-op (quote +)) (= left-op (quote -)))
|
||||
(or
|
||||
(= val "*")
|
||||
(= val "/")
|
||||
(= val "%")
|
||||
(= val "mod")))
|
||||
(and
|
||||
(or
|
||||
(= left-op (quote *))
|
||||
(= left-op (quote /))
|
||||
(= left-op (make-symbol "%")))
|
||||
(or (= val "+") (= val "-"))))
|
||||
(error
|
||||
"You must parenthesize math operations with different operators"))))
|
||||
(adv!)
|
||||
(let
|
||||
((op (cond ((= val "+") (quote +)) ((= val "-") (quote -)) ((= val "*") (quote *)) ((= val "/") (quote /)) ((or (= val "%") (= val "mod")) (make-symbol "%")))))
|
||||
@@ -2648,7 +2701,14 @@
|
||||
((and (= typ "keyword") (= val "answer"))
|
||||
(do (adv!) (parse-answer-cmd)))
|
||||
((and (= typ "keyword") (= val "settle"))
|
||||
(do (adv!) (list (quote settle))))
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((tgt (cond ((at-end?) nil) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "on"))) nil) (true (parse-expr)))))
|
||||
(if
|
||||
(nil? tgt)
|
||||
(list (quote settle))
|
||||
(list (quote settle) tgt)))))
|
||||
((and (= typ "keyword") (= val "go"))
|
||||
(do (adv!) (parse-go-cmd)))
|
||||
((and (= typ "keyword") (= val "return"))
|
||||
@@ -2716,9 +2776,11 @@
|
||||
(adv!)
|
||||
(expect-kw! "view")
|
||||
(expect-kw! "transition")
|
||||
(let ((using (if (match-kw "using") (parse-expr) nil)))
|
||||
(let
|
||||
((using (if (match-kw "using") (parse-expr) nil)))
|
||||
(match-kw "then")
|
||||
(let ((body (parse-cmd-list)))
|
||||
(let
|
||||
((body (parse-cmd-list)))
|
||||
(match-kw "end")
|
||||
(list (quote view-transition!) using body)))))
|
||||
(true (parse-expr))))))
|
||||
@@ -2882,7 +2944,11 @@
|
||||
(true nil))))
|
||||
(true nil))))
|
||||
(consume-having!)
|
||||
(when (and (= (tp-type) "keyword") (= (tp-val) "queue")) (do (adv!) (adv!)))
|
||||
(when
|
||||
(and
|
||||
(= (tp-type) "keyword")
|
||||
(= (tp-val) "queue"))
|
||||
(do (adv!) (adv!)))
|
||||
(let
|
||||
((having (if (or h-margin h-threshold) (dict "margin" h-margin "threshold" h-threshold) nil)))
|
||||
(let
|
||||
|
||||
Reference in New Issue
Block a user