Skip to content

Commit

Permalink
fix #504: where in function name (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub authored Sep 29, 2024
1 parent 9a6d1f1 commit da06e16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TypedSyntax/src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function map_signature!(sig::TypedSyntaxNode, slotnames::Vector{Symbol}, slottyp
# Try to find an identifier for this arg
arg, defaultval = argidentifier(arg)
if arg !== nothing
name = arg.val::Symbol
idx = findfirst(==(name), slotnames)
name = arg.val
idx = name === nothing ? nothing : findfirst(==(name::Symbol), slotnames)
if idx === nothing && isempty(slotarg) && slotnames[1] == Symbol("#self#")
# The first argument is the function name itself, and matches `#self#`
idx = 1
Expand Down
6 changes: 6 additions & 0 deletions TypedSyntax/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,12 @@ include("test_module.jl")
@test_nowarn str = sprint(tsn; context=:color=>false) do io, obj
printstyled(io, obj; hide_type_stable=false)
end

# issue 504
tsn = TypedSyntaxNode(TSN.A504{T, 1} where T, (Vector{Int},))
@test_nowarn str = sprint(tsn; context=:color=>false) do io, obj
printstyled(io, obj; hide_type_stable=false)
end
end

if parse(Bool, get(ENV, "CI", "false"))
Expand Down
3 changes: 3 additions & 0 deletions TypedSyntax/test/test_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ end

f597(var"#"::Int) = 1

struct A504{T, N} end
(A504{T, N} where T)(x::AbstractArray{S, N}) where {S, N} = x

module Internal
export helper
helper(x) = x+1
Expand Down

0 comments on commit da06e16

Please sign in to comment.