Skip to content

Conversation

@yusuftor
Copy link
Contributor

Summary

  • Fixes issue where version strings like "009.000" were incorrectly normalized to Int(9), causing type mismatch errors when compared against string literals
  • When evaluating device.appVersionPadded > "007.003.001", the padded version should remain a string for lexicographic comparison

Changes

  • Added extract_string_compared_variables() function to analyze expressions and identify variables compared against string literals
  • Modified normalize_variables_with_skip() to skip string-to-number conversion for those variables
  • Updated execute_with() and callers to pass the skip set

Example

Before:

device.appVersionPadded > "007.003.001"
# appVersionPadded = "009.000" → normalized to Int(9)
# Error: Int(9) can not be compared to String("007.003.001")

After:

device.appVersionPadded > "007.003.001"  
# appVersionPadded = "009.000" → kept as String("009.000")
# Comparison works correctly: String vs String

Test plan

  • All 105 existing tests pass
  • Manually test with app version "9.0" (2-component) to verify the fix

🤖 Generated with Claude Code

yusuftor and others added 2 commits December 19, 2025 14:55
…ings

When evaluating expressions like `device.appVersionPadded > "007.003.001"`,
the string value "009.000" was incorrectly being normalized to Int(9),
causing a type mismatch error.

The fix:
- Parse the expression first to identify variables compared against string literals
- Skip string-to-number normalization for those variables
- This preserves version strings like "009.000" for proper lexicographic comparison

The solution checks the RHS type of comparison expressions - if a variable is
compared against a string literal, its value is kept as a string even if it
looks like a number.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added test_version_string_comparison_not_normalized_to_number test
- Added test_extract_string_compared_variables test
- Fixed second normalization in device_host_properties that was
  bypassing the skip set

The device properties were being normalized twice:
1. First pass with skip set (correct)
2. Second pass in device_host_properties without skip set (bug)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yusuftor yusuftor requested a review from ianrumac December 19, 2025 17:22
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