-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Getting new compile error on 1.3.0 #4840
Comments
Looking into this a bit on my own, it looks like the problem is on this line: local_for(Module, Name, Arity) ->
local_for(Module, Name, Arity, nil).
local_for(Module, Name, Arity, Given) ->
Tuple = {Name, Arity},
case elixir_def:lookup_clauses(Module, Tuple) of
{Kind, Ann, [_ | _] = Clauses} when Given == nil; Kind == Given ->
get_function(Ann, Module, Clauses);
_ ->
[_ | T] = erlang:get_stacktrace(),
erlang:raise(error, undef, [{Module, Name, Arity, []} | T])
end. The
So it looks like this function needs to be tolerant of getting an empty list? |
It seems the bug has always been there but changes to the compiler is making you trigger it now. I will investigate, calling erlang:get_stacktrace() in there is wrong for all purposes. |
Thanks, @josevalim. If you figure out a work around we can use for this issue, please let me know. We were hoping to deploy 1.3.0 to prod today but are going to hold off until this is fixed since we can't use 1.3.0 in local dev while this is happening. |
@myronmarston I have a fix. diff --git a/lib/elixir/src/elixir_locals.erl b/lib/elixir/src/elixir_locals.erl
index 04d8715..f756a90 100644
--- a/lib/elixir/src/elixir_locals.erl
+++ b/lib/elixir/src/elixir_locals.erl
@@ -31,7 +31,7 @@ local_for(Module, Name, Arity, Given) ->
{Kind, Ann, [_ | _] = Clauses} when Given == nil; Kind == Given ->
get_function(Ann, Module, Clauses);
_ ->
- [_ | T] = erlang:get_stacktrace(),
+ {current_stacktrace, [_ | T]} = erlang:process_info(self(), current_stacktrace),
erlang:raise(error, undef, [{Module, Name, Arity, []} | T])
end. as soon as tests pass I will push to both master and v1.3 branches. |
As a local workaround, this should be enough: alias Delorean.CrawlBuilder.Shaardwolf.{ChunkSelector, ChunkStream}
+require Delorean.CrawlBuilder.Shaardwolf.{ChunkSelector, ChunkStream} This will make sure those modules are loaded upfront so we don't try to load structs dynamically (which is leading to the branch that fails). |
Sounds good, @josevalim! Will 1.3.1 be released with this fix soon? I'm comfortable building from source in the v1.3 branch (I've been doing that for a bit) but my teammates are probably less comfortable with that. |
Thanks! Giving that a try... |
@myronmarston Sorry, you cannot remove the alias, you need both the alias and the require. :) |
Btw, we had a test for this: test "macro with undefined local" do
assert_compile_fail UndefinedFunctionError,
"function Kernel.ErrorsTest.MacroWithUndefinedLocal.unknown/1" <>
" is undefined (function unknown/1 is not available)",
'''
defmodule Kernel.ErrorsTest.MacroWithUndefinedLocal do
defmacrop bar, do: unknown(1)
def baz, do: bar()
end
'''
end But it was not triggering that clause because unfortunately the stacktrace was filled. |
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
I confirmed the workaround you provided fixes the issue for us. Thanks! Now we don't have to wait until 1.3.1 to upgrade :). |
@myronmarston and I can wait a bit more before releasing v1.3.1. :D |
We're running 1.3.0 in prod now :). |
Yay, congrats and thanks for all of the feedback on the prereleases! |
Environment
OS X El Capitan
Current behavior
I'm getting a compile error when compiling my project from within Elixir's erlang source:
Here's the source code of the file that is failing (
lib/shaardwolf.ex
):Note that this compile error consistently happens for me on OS X but I've not seen it happen in our travis builds (which are on linux) so there may be something OS-specific at play here.
Expected behavior
I'd expect it to compile this file without error. Or, if there is a problem with compiling this code, it should fail with a clear error explaining what the problem is instead of crashing with a
MatchError
in the compiler.The text was updated successfully, but these errors were encountered: