Skip to content

Commit

Permalink
Fix/improvement to error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
serenity4 committed Dec 15, 2024
1 parent dd83447 commit 2806450
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/frontend/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ function emit_expression!(mt::ModuleTarget, tr::Translation, target::SPIRVTarget
end
::Core.Argument => throw_compilation_error("call to function argument `$f` detected. All function calls must be made to globally defined symbols; if using a closure, the closure must be inlined")
::GlobalRef => f
_ => throw_compilation_error("call to function argument `$f` detected. All function calls must be made to globally defined symbols")
::Function => throw_compilation_error("`invoke` call to generic function `$f` detected, possibly indicative of a user error")
_ => throw_compilation_error("unhandled call to `$f` of type $(typeof(f))")
end
if f.mod == @__MODULE__() || !in(f.mod, (Base, Core))
opcode = lookup_opcode(f.name)
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function Base.showerror(io::IO, err::CompilationError)
file = contractuser(string(mi.def.file))
ci = retrieve_code_instance(err.target.interp, mi)
rettype = cached_return_type(ci)
line = !isnothing(frame.line) ? frame.line.line : !iszero(err.jinst_index) && i == lastindex(stacktrace) ? getline(err.target.code, err.jinst_index) : mi.def.line
line = !isnothing(frame.line) ? frame.line.line : !iszero(err.jinst_index) && i == lastindex(stacktrace) ? getline(err.target.code, err.jinst_index).line : mi.def.line
print(io, styled"""
\n{$color,$weight: $(here ? '>' : ' ') [$i] $mi::$rettype}
{magenta:@ $(mi.def.module)} {gray:$file:$line}""")
Expand Down

0 comments on commit 2806450

Please sign in to comment.