• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / py-slang / 35224245816
86%

Build:
DEFAULT BRANCH: main
Ran 17 Sep 2026 01:14PM UTC
Jobs 1
Files 139
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

17 Sep 2026 12:58PM UTC coverage: 85.716% (-0.04%) from 85.754%
35224245816

push

github

web-flow
CSE machine: if/elif and conditional expressions require a strict bool condition (#467)

* CSE machine: if/elif and conditional expressions require a strict bool condition

Every spec doc, under "Conditional statements and conditional
expressions", says: "Following if and elif, Python §x only allows
boolean expressions." A companion PR (#439) already tightened this for
the py2js engine and the substitution-model stepper, mirroring the
treatment and/or/not and (separately) while already got. The CSE
machine's BRANCH instruction (src/engines/cse/interpreter.ts) applied
isFalsy's general any-type truthiness unconditionally instead, so e.g.
`if 1: ...` or `1 if "x" else 2` silently took the truthy branch
rather than raising, same as native Python -- unlike this dialect's
own spec.

BRANCH is used by both if/elif and the conditional expression, so one
check-site covers both (matching py2js's shared condBool / the
stepper's shared contractConditional): if the popped condition isn't
already type "bool", raise before falling through to the existing
isFalsy-based branch selection. Distinguishes if vs. ternary only for
the error's wording ("if condition" vs. "conditional expression
condition"), reading instr.srcNode -- already available on every
instruction via BaseInstr, no new field needed.

Added a new ConditionNotBoolError (errors.ts), modeled closely on the
existing ListIndexTypeError/UnsupportedOperandTypeError templates:
neither of those fit directly, since UnsupportedOperandTypeError's
node type is Binary/BoolOp/Unary-only and dereferences node.operator,
which If/Ternary don't have. Uses CSE's own established "friendly type
name, no quotes" phrasing (matching UnsupportedOperandTypeError's
"bad operand type for unary not: boolean" style) rather than
byte-matching py2js/stepper's "predicate type must be 'bool', not
'int'" wording -- per the issue's own allowance for "equivalent
CSE-style wording."

Updates py2js-conditional-bool.test.ts, whose header comm... (continued)

4892 of 6136 branches covered (79.73%)

Branch coverage included in aggregate %.

18 of 18 new or added lines in 2 files covered. (100.0%)

5 existing lines in 1 file now uncovered.

10932 of 12325 relevant lines covered (88.7%)

166402.64 hits per line

Coverage Regressions

Lines Coverage ∆ File
5
88.47
-2.51% src/engines/cse/operators.ts
Jobs
ID Job ID Ran Files Coverage
1 35224245816.1 17 Sep 2026 01:14PM UTC 139
85.72
GitHub Action Run
Source Files on build 35224245816
  • Tree
  • List 139
  • Changed 3
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #35224245816
  • 860b8c9b on github
  • Prev Build on main (#35183864256)
  • Next Build on main (#35230232781)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc