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

Automatic generation of Vex.Extract protocol when using Vex.Struct appears broken in 1.14.1 #71

Closed
darraghenright opened this issue Dec 2, 2022 · 3 comments

Comments

@darraghenright
Copy link

darraghenright commented Dec 2, 2022

Hi folks 👋

I hope all is well. The documentation suggests that protocols are automatically generated for structs when using Vex.Struct but this appears to be broken since 1.14.

I copy-pasted the example presented in the In Structs section of the README to reproduce:

  1. I created a vanilla mix project.
  2. I created a new file called user.ex and copy-pasted the User module from the example into it.
  3. I created a function called validate_user and added the usage example into it.
  4. I ran the command both via the command line with mix run -c and interactively in iex.

Findings:

  • Version 1.12.3-otp-24 works as expected.
  • Version 1.13.4-otp-24 works as expected.
  • Version 1.14.1-otp-24 throws Protocol.UndefinedError.

The full error is:

(Protocol.UndefinedError) protocol Vex.Extract not implemented for %User{username: "actualuser", password: "abcdefghi", password_confirmation: "abcdefghi"} of type User (a struct). This protocol is implemented for the following type(s): Kernel, List, Map, Tuple
(vex 0.9.0) lib/vex/extract.ex:1: Vex.Extract.impl_for!/1
(vex 0.9.0) lib/vex/extract.ex:3: Vex.Extract.settings/1
(vex 0.9.0) lib/vex.ex:14: Vex.valid?/1

I had a look through the 1.14 changelog. Not much jumped out, the only thing I noticed was the following:

[Protocol] Expand :for in protocols with the appropriate env

I don't know if it's related. I'm still looking into that, and will update if I find out anything else.

@darraghenright
Copy link
Author

A small update:

  • The changelog message above is a misnomer, that's from 1.14.2. The functionality is broken since 1.14.1.
  • I can confirm that the functionality does in fact also work in 1.14.0-rc.1 (installed 1.14.0-rc.1-otp-24 via asdf)

So clearly something changed after that release candidate.

@darraghenright darraghenright changed the title Automatic generation of Vex.Extract protocol when using Vex.Struct appears broken since 1.14 Automatic generation of Vex.Extract protocol when using Vex.Struct appears broken in 1.14.1 Dec 2, 2022
@darraghenright
Copy link
Author

Had a quick chat about this in Elixir Slack and turns out this was a bug in Elixir version 1.14.1 which was fixed in 1.14.2:

elixir-lang/elixir#12186

I am happy to confirm that upgrading to 1.14.2 fixes the issue. Closing!

@mudassirkhan19
Copy link

mudassirkhan19 commented Jan 13, 2023

@darraghenright , looks like we are bumping into the same problems across projects 😄

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

No branches or pull requests

2 participants