Skip to content

Infer bounded type for untyped int literals in comparisons#1016

Closed
jcp19 wants to merge 1 commit into
masterfrom
claude/refine-local-plan-3Q2Ip
Closed

Infer bounded type for untyped int literals in comparisons#1016
jcp19 wants to merge 1 commit into
masterfrom
claude/refine-local-plan-3Q2Ip

Conversation

@jcp19
Copy link
Copy Markdown
Contributor

@jcp19 jcp19 commented Apr 19, 2026

opened by mistake in a claude code session

An untyped integer constant appearing as one operand of a comparison (==, !=,
<, <=, >, >=, including ghost equality/inequality) now takes its context type
from the other operand when that operand has a bounded integer type. This
mirrors Go's implicit conversion of untyped constants in comparisons, so the
desugarer and encoding never see mixed-sort operands like Int vs int8.

Implemented by extending getTypeFromCtxt in ExprTyping with cases for the
comparison AST nodes, delegating to a new boundedCtxFromComparison helper
that resolves the other operand's type, unwraps any named wrappers via
underlyingType, and returns the operand's declared type when its kind is a
BoundedIntegerKind.
@jcp19 jcp19 closed this Apr 19, 2026
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