cairo
cairo copied to clipboard
bug: files with syntax error incorrectly reported as well-formatted
Bug Report
Cairo version:
Using the current main
at 5435626
.
Steps to reproduce:
Create an empty folder containing only an unparseable cairo file. Then try to run a formatter check:
$ mkdir fmt_test && cd fmt_test
$ echo "asdf" > file.cairo
$ formatter_cli --check
$ echo $?
Current behavior:
The formatter does indeed report an error regarding the issue: A parsing error occurred in file: ./file.cairo. The file was not formatted.
However, the exit code is 0
, indicating a success:
$ echo $?
0
This would cause CI workflows to give false negative on format errors, since CI workflows would only check the exit code. Editors would also interpret the result as successful and replace file content with the error message.
Expected behavior:
The exit code should be non-zero.
Related code:
This is what's causing the false negative.
https://github.com/starkware-libs/cairo/blob/5435626b17538dbbec6ae1f7706abc8bec212863/crates/formatter/src/bin/cli.rs#L26-L33
Other information:
N/A
For context, cargo fmt
returns 1
if it encounters files with syntax errors.
lgtm