Skip to content

Commit 349873a

Browse files
committed
Handle unary ops when converting typespec to ast
1 parent 66dd76e commit 349873a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# v0.12.1-dev
22

33
* Enhancements
4+
45
* Bug fixes
6+
* [Typespec] - Fix conversion of unary ops from typespec format to ast
7+
58
* Deprecations
9+
610
* Backwards incompatible changes
711

812
# v0.12.0 (2013-12-15)

lib/elixir/lib/kernel/typespec.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ defmodule Kernel.Typespec do
576576
{ erl_to_ex_var(var), line, nil }
577577
end
578578

579+
defp typespec_to_ast({ :op, line, op, arg }) do
580+
{ op, [line: line], [typespec_to_ast(arg)] }
581+
end
582+
579583
# Special shortcut(s)
580584
defp typespec_to_ast({ :remote_type, line, [{:atom, _, :elixir}, {:atom, _, :char_list}, []] }) do
581585
typespec_to_ast({:type, line, :char_list, []})

lib/elixir/test/elixir/typespec_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ defmodule Typespec.TypeTest do
403403
(quote do: @type vaf() :: (... -> any())),
404404
(quote do: @type rng() :: 1 .. 10),
405405
(quote do: @type opts() :: [first: integer(), step: integer(), last: integer()]),
406+
(quote do: @type ops() :: {+1,-1}),
406407
]
407408
408409
types = test_module do

0 commit comments

Comments
 (0)