Origin: Surfaced when the Windows CI matrix entries (added in PR #639 closing #637) ran for the first time. tests/test_codegen.py::TestIOOperations::test_io_read_file_roundtrip fails on Windows with:
lark.exceptions.VisitError: Error trying to process rule "STRING_LIT":
[E009] Error at line 4, column 23:
Invalid escape sequence: \U
The pattern
A test fixture constructs a Vera program containing a string literal with what Vera's grammar interprets as an invalid escape sequence (\U). On Windows, the construction probably embeds a Windows path like C:\Users\runner\... directly into the literal — Vera's parser sees \U and rejects it.
Likely test code shape:
source = f'''
public fn main(-> @Unit) ... {{
IO.write_file("{tmp_path}", "data")
}}
'''
If tmp_path on Windows is C:\Users\runner\AppData\..., the f-string interpolation drops \U literally into the Vera source. Vera's grammar (correctly) treats \U as an invalid escape because Vera doesn't support Python-style \Uxxxxxxxx 8-hex-digit Unicode escapes — and even if it did, \Use isn't valid hex.
Recommended fix
In the failing test, sanitise the path before embedding it into a Vera string literal:
# Bad on Windows:
source = f'IO.write_file("{tmp_path}", ...)'
# Good everywhere — escape backslashes for the Vera string literal:
sanitised = str(tmp_path).replace('\\', '/') # forward slashes work cross-platform
source = f'IO.write_file("{sanitised}", ...)'
Or use pathlib.Path.as_posix() which gives forward-slash form on every OS.
Verify scope
This is reported as one test (test_io_read_file_roundtrip), but other IO.write_file / IO.read_file tests should be audited for the same pattern. Grep tests/ for f-strings that embed tmp_path or similar without sanitisation.
Out of scope
- Adding
\U escape support to Vera's grammar. Vera's escape set is intentionally minimal; expanding it is a language-spec decision unrelated to this Windows fix.
- Generalised path sanitisation in the Vera parser. Vera string literals are opaque to the parser — sanitisation belongs at the test fixture, not in the language.
Acceptance criteria
test_io_read_file_roundtrip passes on windows-latest, 3.{11,12,13}.
- Audit of similar test patterns finds no other latent
\U-class failures.
Pairs with
Origin: Surfaced when the Windows CI matrix entries (added in PR #639 closing #637) ran for the first time.
tests/test_codegen.py::TestIOOperations::test_io_read_file_roundtripfails on Windows with:The pattern
A test fixture constructs a Vera program containing a string literal with what Vera's grammar interprets as an invalid escape sequence (
\U). On Windows, the construction probably embeds a Windows path likeC:\Users\runner\...directly into the literal — Vera's parser sees\Uand rejects it.Likely test code shape:
If
tmp_pathon Windows isC:\Users\runner\AppData\..., the f-string interpolation drops\Uliterally into the Vera source. Vera's grammar (correctly) treats\Uas an invalid escape because Vera doesn't support Python-style\Uxxxxxxxx8-hex-digit Unicode escapes — and even if it did,\Useisn't valid hex.Recommended fix
In the failing test, sanitise the path before embedding it into a Vera string literal:
Or use
pathlib.Path.as_posix()which gives forward-slash form on every OS.Verify scope
This is reported as one test (
test_io_read_file_roundtrip), but otherIO.write_file/IO.read_filetests should be audited for the same pattern. Greptests/for f-strings that embedtmp_pathor similar without sanitisation.Out of scope
\Uescape support to Vera's grammar. Vera's escape set is intentionally minimal; expanding it is a language-spec decision unrelated to this Windows fix.Acceptance criteria
test_io_read_file_roundtrippasses onwindows-latest, 3.{11,12,13}.\U-class failures.Pairs with
/dev/stdin(sibling).