Skip to content

checker: disallow ptr assignments to consts with int literal vals - #19160

Merged
spytheman merged 5 commits into
vlang:masterfrom
ttytm:fix/const-int-literal-ptr
Aug 17, 2023
Merged

spytheman merged 5 commits into
vlang:masterfrom
ttytm:fix/const-int-literal-ptr

Conversation

@ttytm

@ttytm ttytm commented Aug 17, 2023 •

Copy link
Copy Markdown
Member

fixes #19146

πŸ€– Generated by Copilot at 8c04366

Prevent assigning pointers to integer constants in the V compiler. Improve error message and suggestion for constant declarations.

πŸ€– Generated by Copilot at 8c04366

  • Add a check to prevent assigning a pointer to a constant integer literal (link)
  • Provide an error message and a suggestion to specify the type for the constant value (link)

@ttytm
ttytm marked this pull request as draft August 17, 2023 14:53
4 | b := &a
| ^
5 | }
Details: Specify the type for the constant value. Example:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems like these details should come after the error message.

This comment was marked as outdated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Though I should not make the added tests produce an unused error

@ttytm
ttytm marked this pull request as ready for review August 17, 2023 18:55
@spytheman
spytheman merged commit 4908ec5 into vlang:master Aug 17, 2023
@ttytm
ttytm deleted the fix/const-int-literal-ptr branch August 22, 2023 13:32
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.

C error when assigning variable to const int_type ptr

3 participants