Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 29, 2026

This PR fixes critical bugs found during code review:

SecurityAnalyzer Fixes

Class Name Typos

  • Fixed "Analzyer" -> "Analyzer" in 3 files:
    • : ->
    • : ->
    • : Class name ->
    • : Class name ->

Critical Logic Bugs in UpdateAnalyzer

  • Line 45: Fixed wrong bitwise operator -> for CallFlags check

    • Old: (always true!)
    • New:
  • Line 53: Fixed byte array comparison ->

    • Old: (reference equality)
    • New:

WriteInTryAnalyzer Compilation Fix

  • Added missing helper method

Peephole Optimizer Fixes

Operator Precedence Bugs (3 occurrences)

Fixed incorrect pattern matching due to having higher precedence than :

  • Line 127-129: - now properly grouped
  • Line 160-162: - now properly grouped
  • Line 247-249: - now properly grouped

Instruction Disassembler Fix

  • Fixed incorrect span offset for PUSHDATA2/PUSHDATA4 string extraction
    • PUSHDATA2: -> (2-byte size prefix)
    • PUSHDATA4: -> (4-byte size prefix)

Testing

All 944 compiler unit tests pass after these changes.

SecurityAnalyzer fixes:
- Fix typos: Analzyer -> Analyzer in class names (3 occurrences)
- Fix wrong bitwise operator | -> & in UpdateAnalyzer (CallFlags check)
- Fix byte array comparison == -> SequenceEqual in UpdateAnalyzer
- Add missing GetSourceLocation helper in WriteInTryAnalyzer

Peephole optimizer fixes:
- Fix operator precedence bugs in pattern matching (3 occurrences)
  - (A && B || C) -> ((A && B) || C)

Instruction disassembler fix:
- Fix incorrect span offset for PUSHDATA2/PUSHDATA4 string extraction
  - PUSHDATA2: AsSpan(1) -> AsSpan(2)
  - PUSHDATA4: AsSpan(1) -> AsSpan(4)

All 944 compiler unit tests pass.
@Jim8y Jim8y marked this pull request as draft January 29, 2026 09:12
Jim8y added 8 commits January 29, 2026 17:40
…g fixes

Add unit tests demonstrating fixes for:

1. UpdateAnalyzer security fixes:
   - Test_CallFlags_BitwiseOperator_Fix: Verifies (flags | WriteStates) -> (flags & WriteStates)
   - Test_ByteArray_Comparison_Fix: Verifies SequenceEqual vs reference equality

2. Peephole optimizer fixes:
   - Tests for operator precedence fixes in pattern matching
   - Tests verify optimization doesn't crash on various patterns

3. Instruction disassembler fixes:
   - Tests for PUSHDATA2/PUSHDATA4 span offset fixes
   - Tests verify correct data extraction from operands

Also update existing WriteInTry tests to use corrected class name (WriteInTryAnalyzer).

All 961 compiler unit tests pass.
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.

1 participant