Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pio: Assembler: fix issue in diag when tokenizer has index on newline #347

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

Grazfather
Copy link
Contributor

If the tokenizer index is at the newline at the end of a line and it initializes the diagnostics, the column calculation will underflow, since the line iterator index will point to the end of the next line, while the index will be the previous new line character, so the column will be calculated as -1.

This change simply allows the index to point to the newline, though in this case the diagnostic will point past the end of the line:

zig build test --summary all
test
└─ run test
   └─ zig test Debug native 1 errors
src/hal/pio/assembler.zig:133:13: error: failed to assemble PIO code:

                                             mov osr, rxfifoy
                                                             ^
                                                             hello 155

            @compileError(format_compile_error(d.message.slice(), source, d.index));
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hal/pio/assembler/comparison_tests.zig:57:47: note: called from here
    const output = comptime assembler.assemble(cpu, source, .{});
                            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

@Grazfather Grazfather marked this pull request as ready for review January 7, 2025 14:25
@mattnite mattnite merged commit af5f3d8 into ZigEmbeddedGroup:main Jan 9, 2025
27 checks passed
@Grazfather Grazfather deleted the pio_tokenizer_diag_fix branch January 10, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants