Skip to content

Return early on SizeOf-like generic args in non-raising lookup#16811

Open
kojix2 wants to merge 3 commits intocrystal-lang:masterfrom
kojix2:type-lookup-return
Open

Return early on SizeOf-like generic args in non-raising lookup#16811
kojix2 wants to merge 3 commits intocrystal-lang:masterfrom
kojix2:type-lookup-return

Conversation

@kojix2
Copy link
Copy Markdown
Contributor

@kojix2 kojix2 commented Apr 6, 2026

Hello.

This pull request aims to fix #14731.
It is also a follow-up to #12577.

When TypeLookup#lookup(node : Generic) runs in type inference, SizeOf and similar nodes in generic arguments should stop the lookup and return nil. It should not continue to the next argument.
If it continues with next, the generic argument list can become invalid and cause an internal error.

This was researched and created with help from GPT-5.4 in VSCode Copilot Chat.

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic labels Apr 7, 2026
Copy link
Copy Markdown
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Maybe we should add a comment to these examples that they should not produce an error once #5427 is implemented?

It has been proposed to allow integer expressions and `sizeof()` as part
of type notation.(crystal-lang#5427)

This reverts commit d172bb3.
@kojix2
Copy link
Copy Markdown
Contributor Author

kojix2 commented Apr 8, 2026

Since the expected behavior has not been agreed on yet, I removed the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error when using sizeof as generic type argument in inferred ivar type

2 participants