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

Seems broken on Elixir 1.14.0 #31

Open
ejpcmac opened this issue Sep 11, 2022 · 5 comments
Open

Seems broken on Elixir 1.14.0 #31

ejpcmac opened this issue Sep 11, 2022 · 5 comments
Assignees
Labels
T:Bug Type: Bug

Comments

@ejpcmac
Copy link
Owner

ejpcmac commented Sep 11, 2022

When running the tests on Elixir 1.14.0 / OTP 24, I can see a lot of failures. After my first investigations it seems that neither the @type nor the @enforce_keys seem to be generated. The struct itself is generated though.

@ejpcmac ejpcmac added the T:Bug Type: Bug label Sep 11, 2022
@ejpcmac ejpcmac self-assigned this Sep 11, 2022
@ejpcmac
Copy link
Owner Author

ejpcmac commented Sep 18, 2022

It seems to be due to a bug in Elixir. Let’s try on Elixir 1.14.1 when it is out.

@saleyn
Copy link

saleyn commented Sep 27, 2022

I checked with Elixir 1.14.0, and it seems like the struct and the type is properly generated, but the tests do fail.

@asmodehn
Copy link

asmodehn commented Mar 3, 2023

So I checked on v0.3.0 (via asdf instead of nix):

elixir 1.14.3-otp-25
erlang 25.1.2

mix test gives:

==> typed_struct
Compiling 2 files (.ex)
Generated typed_struct app
..

  1) test generates an opaque type if `opaque: true` is set (TypedStructTest)
     test/typed_struct_test.exs:133
     ** (FunctionClauseError) no function clause matching in TypedStructTest.standardise/2

     The following arguments were given to TypedStructTest.standardise/2:
     
         # 1
         nil
     
         # 2
         TypedStructTest.OpaqueTestStruct
     
     code: |> standardise(TypedStructTest.OpaqueTestStruct)
     stacktrace:
       test/typed_struct_test.exs:250: TypedStructTest.standardise/2
       test/typed_struct_test.exs:149: (test)

.

  2) test aliases are properly resolved in types (TypedStructTest)
     test/typed_struct_test.exs:207
     ** (FunctionClauseError) no function clause matching in TypedStructTest.standardise/2

     The following arguments were given to TypedStructTest.standardise/2:
     
         # 1
         nil
     
         # 2
         TypedStructTest.TestStructNoAlias
     
     code: |> standardise(TypedStructTest.TestStructNoAlias)
     stacktrace:
       test/typed_struct_test.exs:250: TypedStructTest.standardise/2
       test/typed_struct_test.exs:224: (test)

..

  3) test generates a type for the struct (TypedStructTest)
     test/typed_struct_test.exs:107
     ** (FunctionClauseError) no function clause matching in TypedStructTest.standardise/2

     The following arguments were given to TypedStructTest.standardise/2:
     
         # 1
         nil
     
         # 2
         TypedStructTest.TestStruct
     
     code: type1 = @bytecode |> extract_first_type() |> standardise()
     stacktrace:
       test/typed_struct_test.exs:250: TypedStructTest.standardise/2
       test/typed_struct_test.exs:123: (test)

.....................
Finished in 0.2 seconds (0.00s async, 0.2s sync)
29 tests, 3 failures

So it looks like a failure happened and extract_first_type returns nil if Code.Typespec.fetch_types(bytecode) doesnt return an {:ok, _ } tuple. Besides that I m not sure what happened...

@saleyn
Copy link

saleyn commented Jun 17, 2023

This is fixed in my PRs #39 and #40.

@saleyn
Copy link

saleyn commented Sep 30, 2023

See this fork, which is compatible with OTP-26 and Elixir 1.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:Bug Type: Bug
Projects
Status: Backlog
Development

No branches or pull requests

3 participants