Skip to content

Remove type binding on T for Pointer(T)#value=#15751

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/pointer-set-bind
May 8, 2025
Merged

Remove type binding on T for Pointer(T)#value=#15751
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/pointer-set-bind

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented May 6, 2025

Fixes #15742. Does not fix the first snippet of #15742 (comment) (this is a different bug that also occurs on compilers before 1.16).

Only the type of a whole assignment (ptr.value = x) needs to be bound to the right-hand side's type. The element type of ptr shall be inferred from the assignments to ptr itself, and I don't think it makes sense to do this from the individual #value= calls.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic kind:regression Something that used to correctly work but no longer works labels May 6, 2025
@ysbaddaden
Copy link
Collaborator

Is it even possible to infer the pointer element type? 🤔

We can either Pointer(T).new(address) or pointerof(x) and both will have an explicit type. Even a loose Pointer type constraint will always have a concrete T.

@straight-shoota straight-shoota added this to the 1.16.3 milestone May 6, 2025
@straight-shoota straight-shoota merged commit 319d7e7 into crystal-lang:master May 8, 2025
38 of 39 checks passed
@crysbot
Copy link
Collaborator

crysbot commented May 8, 2025

Successfully created backport PR for release/1.16:

straight-shoota pushed a commit that referenced this pull request May 8, 2025
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
@HertzDevil HertzDevil deleted the bug/pointer-set-bind branch May 15, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release/1.16 kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid memory access (signal 11) at address 0x0 on Crystal 1.16.x

4 participants