Skip to content

fix(core): make ValueKind.Int32 coercion follow the device integer rule (#1271) - #1305

Merged
lvcabral merged 1 commit into
masterfrom
fix/int32-arg-coercion-1271
Nov 1, 2026
Merged

lvcabral merged 1 commit into
masterfrom
fix/int32-arg-coercion-1271

Conversation

@lvcabral

@lvcabral lvcabral commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Closes #1271.

tryCoerce built Integer values with new Int32(value), so a NaN Float/Double stayed NaN, unlike the ValueKind.Dynamic + toIntegerArg parameters. The Int32 target now uses toArrayIndex: Float/Double are truncated (NaN as 0) and a LongInteger keeps its low 32 bits.

tryCoerce is shared, so this also applies to x% assignments and typed function returns (NaN becomes 0 instead of staying NaN).

Tests: NaN and negative-fraction cases added to test/brsTypes/TypeCoercion.test.js; full suite passes. Not re-checked against a device.

🤖 Generated with Claude Code

…le (#1271)

tryCoerce built Integer values with new Int32(value), so a NaN Float/Double
stayed NaN and neighbouring built-in methods read the same argument
differently from the Dynamic + toIntegerArg ones. Use toArrayIndex so
Float/Double are truncated (NaN as 0) and a LongInteger keeps its low 32 bits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

@lvcabral
lvcabral merged commit efaf4bd into master Nov 1, 2026
3 checks passed
@lvcabral
lvcabral deleted the fix/int32-arg-coercion-1271 branch November 1, 2026 01:35
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.

Unify Integer argument coercion: ValueKind.Int32 parameters vs toIntegerArg

1 participant