Skip to content
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

kwcall appearing in stacktraces #47319

Closed
vtjnash opened this issue Oct 25, 2022 · 3 comments · Fixed by #47373
Closed

kwcall appearing in stacktraces #47319

vtjnash opened this issue Oct 25, 2022 · 3 comments · Fixed by #47373
Labels
error messages Better, more actionable error messages regression Regression in behavior compared to a previous version
Milestone

Comments

@vtjnash
Copy link
Member

vtjnash commented Oct 25, 2022

I have been seeing kwcall in stacktraces, and need to figure out how to reproduce it. It seems my mistake is here:

diff --git a/base/errorshow.jl b/base/errorshow.jl
index 16190d64e0..65d761aefe 100644
--- a/base/errorshow.jl
+++ b/base/errorshow.jl
@@ -850,10 +850,8 @@ function process_backtrace(t::Vector, limit::Int=typemax(Int); skipC = true)
             code = lkup.linfo
             if code isa MethodInstance
                 def = code.def
-                if def isa Method
-                    if def.name === :kwcall && def.module === Core
-                        continue
-                    end
+                if def isa Method && def.sig <: Tuple{typeof(Core.kwcall),Vararg}
+                    continue
                 end
             elseif !lkup.from_c
                 lkup.func === :kwcall && continue

Originally posted by @vtjnash in #47157 (comment)

@vtjnash vtjnash added regression Regression in behavior compared to a previous version display and printing Aesthetics and correctness of printed representations of objects. error messages Better, more actionable error messages and removed display and printing Aesthetics and correctness of printed representations of objects. labels Oct 25, 2022
@vchuravy vchuravy added this to the 1.9 milestone Oct 25, 2022
@gbaraldi
Copy link
Member

https://buildkite.com/julialang/julia-master/builds/17475#0184118b-9227-4abd-b2c8-132b19d74672 I saw it here on both macos tests. Seems worrying

@vtjnash
Copy link
Member Author

vtjnash commented Oct 26, 2022

That doesn't seem to have anything to do with this. Did you mean to make a new issue?

@gbaraldi
Copy link
Member

Oh, it was just another case kwcall in stacktraces.

vtjnash added a commit that referenced this issue Oct 28, 2022
They are not strictly internal, but also not strictly external, so just
assume they should be hidden.

Perhaps, in the future, we should figure out a way to signal directly in
the line number value that this line can be hidden, so only exactly the
inner call gets hidden, but not errors that happen in the kwsorter
itself (for example, for computing default values). Then all of these
could print comparable backtraces (rather than just hiding the kwcall,
as this PR does):

```
julia> f(; a, b) = error()
f (generic function with 1 method)

julia> f()
ERROR: UndefKeywordError: keyword argument `a` not assigned
Stacktrace:
 [1] f()
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[2]:1

julia> f(b=1)
ERROR: UndefKeywordError: keyword argument `a` not assigned
Stacktrace:
 [1] kwcall(::NamedTuple{(:b,), Tuple{Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[3]:1

julia> f(a=1)
ERROR: UndefKeywordError: keyword argument `b` not assigned
Stacktrace:
 [1] kwcall(::NamedTuple{(:a,), Tuple{Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[4]:1

julia> f(a=1, b=2)
ERROR:
Stacktrace:
 [1] error()
   @ Base ./error.jl:44
 [2] f(; a::Int64, b::Int64)
   @ Main ./REPL[1]:1
 [3] kwcall(::NamedTuple{(:a, :b), Tuple{Int64, Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [4] top-level scope
   @ REPL[5]:1
```

Fix #47319
vtjnash added a commit that referenced this issue Nov 1, 2022
They are not strictly internal, but also not strictly external, so just
assume they should be hidden.

Perhaps, in the future, we should figure out a way to signal directly in
the line number value that this line can be hidden, so only exactly the
inner call gets hidden, but not errors that happen in the kwsorter
itself (for example, for computing default values). Then all of these
could print comparable backtraces (rather than just hiding the kwcall,
as this PR does):

```
julia> f(; a, b) = error()
f (generic function with 1 method)

julia> f()
ERROR: UndefKeywordError: keyword argument `a` not assigned
Stacktrace:
 [1] f()
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[2]:1

julia> f(b=1)
ERROR: UndefKeywordError: keyword argument `a` not assigned
Stacktrace:
 [1] kwcall(::NamedTuple{(:b,), Tuple{Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[3]:1

julia> f(a=1)
ERROR: UndefKeywordError: keyword argument `b` not assigned
Stacktrace:
 [1] kwcall(::NamedTuple{(:a,), Tuple{Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[4]:1

julia> f(a=1, b=2)
ERROR:
Stacktrace:
 [1] error()
   @ Base ./error.jl:44
 [2] f(; a::Int64, b::Int64)
   @ Main ./REPL[1]:1
 [3] kwcall(::NamedTuple{(:a, :b), Tuple{Int64, Int64}}, ::typeof(f))
   @ Main ./REPL[1]:1
 [4] top-level scope
   @ REPL[5]:1
```

Fix #47319
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Better, more actionable error messages regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants