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

Add typespec/1 macro to transform module behaviour #384

Merged
merged 8 commits into from
Dec 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
v0idpwn committed Dec 22, 2024
commit 02daaf47b4ca0f1c7515cbd2d469132d7b829901
6 changes: 3 additions & 3 deletions lib/protobuf/dsl.ex
Original file line number Diff line number Diff line change
@@ -254,11 +254,11 @@ defmodule Protobuf.DSL do
_ ->
raise CompileError, """
Transform module #{inspect(unquote(transform_module_ast))} not available
during protobuf definition compilation.
during Protobuf definition compilation.

Since protobuf v0.14, protobuf definitions depend in compile time on
Since Protobuf v0.14, Protobuf definitions depend in compile time on
their transform modules. This means that transform modules can't depend
on protobuf structs, and must be available for compilation when protobuf
on Protobuf structs, and must be available for compilation when Protobuf
definitions are compiled.
"""
end
2 changes: 1 addition & 1 deletion lib/protobuf/transform_module.ex
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ defmodule Protobuf.TransformModule do
@callback decode(message(), type()) :: value()

@doc """
Transforms the typespec for modules using this transformer
Transforms the typespec for modules using this transformer.

If this callback is not present, the default typespec will be used.
"""

Unchanged files with check annotations Beta

@impl true
defmacro typespec(default_typespec) do
case module do

Check warning on line 259 in test/support/test_msg.ex

GitHub Actions / Test (Elixir 1.12.3 | Erlang/OTP 24.3)

variable "module" does not exist and is being expanded to "module()", please use parentheses to remove the ambiguity or change the variable name

Check failure on line 259 in test/support/test_msg.ex

GitHub Actions / Test (Elixir 1.12.3 | Erlang/OTP 24.3)

** (CompileError) test/support/test_msg.ex:259: undefined function module/0

Check warning on line 259 in test/support/test_msg.ex

GitHub Actions / Conformance test (Elixir 1.14 | Erlang/OTP 24.2)

variable "module" does not exist and is being expanded to "module()", please use parentheses to remove the ambiguity or change the variable name

Check failure on line 259 in test/support/test_msg.ex

GitHub Actions / Conformance test (Elixir 1.14 | Erlang/OTP 24.2)

** (CompileError) test/support/test_msg.ex:259: undefined function module/0 (expected TestMsg.TransformModule to define such a function or for it to be imported, but none are available)
WithTransformModule ->
quote do
@type t() :: integer()