Skip to content

in with a number, a boolean or a bigint on the right is an error - #584

Merged
ASDAlexander77 merged 1 commit into
mainfrom
in-primitive-error
Oct 17, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
in-primitive-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

"a" in 5 compiled with no diagnostic and was false: the field lookup on a number found nothing.

Fix: mlirGenInLogic rejects a number, boolean or bigint (literal or enum types included) on the right of in, at the right operand, with TypeScript's message.

Repro (diagnostic-location/in_primitive.ts):

function main() {
    const s = "hello";
    print("length" in s);
    print("a" in 5);   // 7:18: error: The right-hand side of an 'in' expression must not be a primitive: '5'
}

Kept on purpose: a string on the right ("length" in s, asserted by tests/00in_method_names.ts). TypeScript rejects it too, but the corpus treats it as an extension. Line 6 of the test must stay error-free.

ctest -C Release -j 8 --timeout 300: 100% passed, 0 failed (4092 tests on this branch).

🤖 Generated with Claude Code

`"a" in 5` compiled with no diagnostic and was false: the field lookup
on a number found nothing. TypeScript rejects a primitive on the right
of `in`; so does tslang now, at the right operand. A string on the
right stays an extension (`"length" in s`, tests/00in_method_names.ts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit d63ef4a into main Oct 17, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the in-primitive-error branch October 17, 2026 14:14
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