';'-separated statements fail at an imported module's top level
# scmod.py
a = 1; b = 2 # pascal26:1: error: expected expression
# scmain.npy
import scmod
print(scmod.a + scmod.b) # CPython: 3
Cause and fix
pyparser.inc has three statement loops:
- the program loop;
- PyParseBlock, for every indented suite;
- the imported module's top-level loop.
The first two consume ; and parse the next simple statement on the same
line. The module loop parsed one statement and then returned to its line
loop, where the ; began a statement and failed. The module loop's
ordinary-statement arm now repeats while a ; follows, and stops at a
trailing ;, as the other two loops do.
Measured (2026-09-29, fixedpoint 14a778a7c574)
-
test/test_nilpy_semicolons_at_an_imported_modules_top_level.npy, with its moduletest/semimod.py, covers:- assignments and augmented assignments;
- calls;
- a trailing
;; - a one-line
ifsuite and a one-lineforsuite; - a string after the
;.
It equals CPython on x86-64, i386, riscv32, arm32 and wasm32. With the previous compiler, it does not build on any of them. The rows are x86-64, i386 and wasm32.
-
test_nilpy_chained_assign_nested_attr,test_nilpy_chained_assign_powassignandtest_nilpy_suites, compiled as an imported module under a one-lineimportmain, now equal CPython on x86-64. With the previous compiler, all three failed to build.
Not covered: a separate defect
class P: with k = 1; j = 2 in its body fails with class method not found: j
in a main program as well, so it is not this loop. Its cause was not
investigated here, and it was reported to the coordinator.