Skip to content

bad stack trace for errors in macros #15643

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

Closed
SimonDanisch opened this issue Mar 27, 2016 · 1 comment
Closed

bad stack trace for errors in macros #15643

SimonDanisch opened this issue Mar 27, 2016 · 1 comment
Assignees

Comments

@SimonDanisch
Copy link
Contributor

macro test(x)
    if x.head == :(=)
        return :()
    elseif x.head == :(.)e # errors here
        return :()
    end
    return :()
end

begin



@test a = b
@test a.b


end

0.4:

ERROR: LoadError: MethodError: `*` has no method matching *(::Symbol, ::Irrational{:e})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...)
  *{T<:Number}(!Matched::Bool, ::T<:Number)
  *(!Matched::Complex{Bool}, ::Real)
  ...
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:280
 in _start at ./client.jl:378
while loading /home/s/.julia/v0.5/FixedSizeDictionaries/test/runtests.jl, in expression starting on line 20

Note that this is the line number after the actual begin block.
0.5:

ERROR: LoadError: MethodError: no method matching *(::Symbol, ::Irrational{:e})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...)
  *{T<:Number}(!Matched::Bool, ::T<:Number)
  *(!Matched::Complex{Bool}, ::Real)
  ...
 in include(::ASCIIString) at ./boot.jl:240
 in include_from_node1(::UTF8String) at ./loading.jl:417
 in process_options(::Base.JLOptions) at ./client.jl:262
 in _start() at ./client.jl:318
while loading /home/s/.julia/v0.5/FixedSizeDictionaries/test/runtests.jl, in expression starting on line 11

it's a bit better, but still not that great. Especially, since even without the block, it still doesn't report the line number in the macro, and the macro can be arbitrarily deep in the stack trace but it will only report one line number...
julia --inline=no doesn't change anything.
Versions:

julia> versioninfo()
Julia Version 0.5.0-dev+3280
Commit b410b87* (2016-03-27 02:59 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

and

julia> versioninfo()
Julia Version 0.4.3
Commit a2f713d (2016-01-12 21:37 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@vtjnash saying:

it happens because the error doesn't get thrown directly, but instead gets unwound through flisp and is thrown directly by eval:

   424      else if (ex->head == error_sym || ex->head == jl_incomplete_sym) {
   425          if (nargs == 0)
   426              jl_error("malformed \"error\" expression");
   427          if (jl_is_byte_string(args[0]))
   428              jl_errorf("syntax: %s", jl_string_data(args[0]));
   429          jl_throw(args[0]); # <--- backtrace collected from here
   430      }

initially reported in #10595

@SimonDanisch
Copy link
Contributor Author

Basically the same on windows for 0.4 and 0.5!

@vtjnash vtjnash self-assigned this Aug 3, 2017
vtjnash added a commit that referenced this issue Aug 10, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
vtjnash added a commit that referenced this issue Aug 11, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
vtjnash added a commit that referenced this issue Aug 31, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
vtjnash added a commit that referenced this issue Aug 31, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
vtjnash added a commit that referenced this issue Aug 31, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
vtjnash added a commit that referenced this issue Sep 5, 2017
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
@vtjnash vtjnash closed this as completed in d7169ae Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants