Skip to content

underscores still allowed as static parameter names #30162

Open
@timholy

Description

@timholy

In combination with Revise, some code (in ImageFiltering) that was initially written prior to the Julia-0.6 type system overhaul exposed the following inconsistency:

julia> foo(A::AbstractArray{_,N}, flags::NTuple{N,Bool}) where {_,N} = 1
foo (generic function with 1 method)                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                   
julia> foo(rand(2,2), (true, true))   # just to prove that the method works
1                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                   
julia> Tuple{AbstractArray{_,N}, NTuple{N,Bool}} where {_,N}   # create the signature type
ERROR: syntax: all-underscore identifier used as rvalue

Obviously, post-0.6 the better way to write this is

julia> foo(A::AbstractArray{<:Any,N}, flags::NTuple{N,Bool}) where N = 1
foo (generic function with 1 method)

julia> Tuple{AbstractArray{<:Any,N}, NTuple{N,Bool}} where N
Tuple{AbstractArray{#s3,N} where #s3,Tuple{Vararg{Bool,N}}} where N

but the inconsistency should be fixed. In principle it seems that either option would be OK (throw an error on the method definition, or allow the Tuple-type to be created), with the obvious caveat that one of these is breaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions