Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update argument error message when matching with <> #13325

Merged
merged 2 commits into from Feb 9, 2024

Conversation

sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Feb 8, 2024

The error message for var <> "suffix" = hasn't been updated following the support of pinned variables on the left-handside operand.

** (ArgumentError) the left argument of <> operator inside a match should always be a literal binary because its size can't be verified. Got: var

Updated message:

** (ArgumentError) the left argument of <> operator inside a match should always be either a literal binary or an existing variable matched with the pin operator (such as ^some_var) because its size can't be verified. Got: var

Based the phrasing on the similar error following %{var => 1} = 1

error: cannot use variable var as map key inside a pattern. Map keys in patterns can only be literals (such as atoms, strings, tuples, and the like) or an existing variable matched with the pin operator (such as ^some_var)

lib/elixir/lib/kernel.ex Outdated Show resolved Hide resolved
Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

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

I suggested improvements, then please ship it (and backport!).

Co-authored-by: José Valim <jose.valim@gmail.com>
@sabiwara sabiwara merged commit 3fb82c3 into elixir-lang:main Feb 9, 2024
3 of 8 checks passed
@sabiwara sabiwara deleted the bin_match_error_message branch February 9, 2024 07:49
@sabiwara sabiwara mentioned this pull request Feb 9, 2024
@sabiwara
Copy link
Contributor Author

sabiwara commented Feb 9, 2024

Sorry I merged too fast, the suggestion broke the test.
Will backport together with #13327.

sabiwara added a commit that referenced this pull request Feb 9, 2024
* Update argument error message when matching with <>

* Update lib/elixir/lib/kernel.ex

Co-authored-by: José Valim <jose.valim@gmail.com>

---------

Co-authored-by: José Valim <jose.valim@gmail.com>
@sabiwara
Copy link
Contributor Author

sabiwara commented Feb 9, 2024

Thanks! Backported

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

Successfully merging this pull request may close these issues.

None yet

2 participants