[proposal] make a warning when trying to use Capital word in module attributes like "@A" or support it

23 views
Skip to first unread message

forbitc...@gmail.com

unread,
Mar 23, 2019, 6:49:08 PM3/23/19
to elixir-lang-core
When compile this:

```
defmoudle M do

  @A
  IO.inspect @A

end
```

result is:

```
:ok
warning: module attribute @__aliases__ was set but never used
```

It's because of the AST of `@A` is
```
iex(1)> quote do 
...(1)> @A
...(1)> end
{:@, [context: Elixir, import: Kernel],
 [{:__aliases__, [context: Elixir, alias: false], [:A]}]}
```

and the AST of `@a 1` is
```
iex(2)> quote do
...(2)> @a 1
...(2)> end
{:@, [context: Elixir, import: Kernel], [{:a, [context: Elixir], [1]}]}
```

So, the compiler just read `@A` as "@__aliases__ :A". 

Current warning message is hard to reason about. Maybe we can have a better warning message, or support the capital module attributes.

José Valim

unread,
Mar 24, 2019, 3:12:28 AM3/24/19
to elixir-l...@googlegroups.com
Yes, please open up an issue.
--


José Valim
Skype: jv.ptec
Founder and Director of R&D
Reply all
Reply to author
Forward
0 new messages