IvanRublev / Domo

A library to validate values of nested structs with their type spec t() and associated precondition functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Domo Compiler tripped up by Ecto.Schema.Metadata type

capitalist opened this issue · comments

Environment

  • Elixir version (elixir -v): Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit] Elixir 1.12.2 (compiled with Erlang/OTP 24)
  • Domo version (mix deps | grep domo | head -1): locked at 1.3.3 (domo) 10374b4a
  • TypedStruct version (mix deps | grep typed_struct | head -1): not present

Actual behavior

** (MatchError) no match of right hand side value: {:"::", [], [{:t, [], []}, {:t, [line: 50], [{:module, [line: 50], []}]}]}
   (domo 1.3.3) lib/domo/type_ensurer_factory.ex:37: Domo.TypeEnsurerFactory.collect_types_for_domo_compiler/3
    (elixir 1.12.2) lib/enum.ex:930: Enum."-each/2-lists^foreach/1-0-"/2
    (domo 1.3.3) lib/mix/tasks.compile.domo_compiler.ex:73: Mix.Tasks.Compile.DomoCompiler.build_ensurer_modules/2
    (domo 1.3.3) lib/mix/tasks.compile.domo_compiler.ex:57: Mix.Tasks.Compile.DomoCompiler.run/1
    (mix 1.12.2) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.12.2) lib/mix/tasks/compile.all.ex:92: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.12.2) lib/mix/tasks/compile.all.ex:72: Mix.Tasks.Compile.All.compile/4
    (mix 1.12.2) lib/mix/tasks/compile.all.ex:59: Mix.Tasks.Compile.All.with_logger_app/2

Expected behavior

Compiles

It turns out that Domo is compatible with Ecto of versions <= 3.6.2 and fails to import Schema type with Ecto releases 3.7.x.
Let's see what can be done to level up the compatibility.

So, locally I just dropped another clause in the case to prevent the error but I'm just discarding type information so it's not a proper fix.

What I'm worried is that this makes you have to open the self-referential types 'can of worms' but I don't know enough about it to tell.

What I can tell you is just playing with Domo on a side project, it immediately surface potential bug sources 👍

Hey,

I'm delighted to hear that Domo spotlighted potential bug sources for you!

Domo doesn't support self-referenced types. So no trees validation is possible yet 😄

The Ecto.Schema.Metadata issue is fixed with version 1.3.4, please, give it a try.

I can confirm this fixes the issue.