Skip to content

Improve error messages for expressions - #184

Merged
yunzheng merged 1 commit into
mainfrom
improve-expression-errors
Nov 5, 2026
Merged

yunzheng merged 1 commit into
mainfrom
improve-expression-errors

Conversation

@Schamper

@Schamper Schamper commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Improves error messages thrown about invalid expressions. Namely:

  • Remove line numbers from Expression errors
    • This may sound counterintuitive, but Expressions do their own tokenization from a string, so every error was "line 1" anyway, no matter where the Expression was created from
  • Add explicit UnknownIdentifierError for missing identifiers
  • Re-raise Expression errors with the correct line number as ParserError

This surpasses #171

@Schamper
Schamper requested a review from yunzheng November 5, 2026 22:28
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (e066596) to head (c5b0ded).

Files with missing lines Patch % Lines
dissect/cstruct/parser.py 0.00% 16 Missing ⚠️
dissect/cstruct/expression.py 0.00% 14 Missing ⚠️
dissect/cstruct/lexer.py 0.00% 6 Missing ⚠️
dissect/cstruct/exception.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #184   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         22      22           
  Lines       3554    3562    +8     
=====================================
- Misses      3554    3562    +8     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 45 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing improve-expression-errors (c5b0ded) with main (e066596)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread tests/test_parser.py Resolved
@Schamper
Schamper force-pushed the improve-expression-errors branch from 3cef78b to c5b0ded Compare November 5, 2026 22:57
@Schamper
Schamper requested a review from yunzheng November 5, 2026 22:57
@yunzheng
yunzheng merged commit 0db7535 into main Nov 5, 2026
24 checks passed
@yunzheng
yunzheng deleted the improve-expression-errors branch November 5, 2026 23:03
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