HS: mixed-op enforcement + short-circuit + typecheck + strings (+7 tests)
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:
2026-05-04 11:31:56 +00:00
parent 894fd24c3a
commit 51bc075da5
5 changed files with 240 additions and 43 deletions

View File

@@ -931,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
@@ -2156,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 "%")))))