Skip to content

Erroneous warning when using types in keyword argument function declaration #49275

@mmiller-max

Description

@mmiller-max

If I have a function with a nested type delegation (two wheres), I get the following incorrect warning

julia> foo(;a::T) where {T<:AbstractVector{N}} where {N} = zero(N)
WARNING: method definition for foo at REPL[5]:1 declares type variable N but does not use it.
WARNING: method definition for foo##kw at REPL[5]:1 declares type variable N but does not use it.
foo (generic function with 1 method)

It is being used, as can be seen by these two executions of the function

julia> foo(a=[1.0])
0.0

julia> foo(a=[1])
0

If I do something similar without nesting the type, it works fine with no warning

julia> bar(;a::N) where {N} = zero(N)
bar (generic function with 1 methods)

Ran on 1.8.5 and latest 1.9 RC

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.5.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
julia> versioninfo()
Julia Version 1.9.0-rc2
Commit 72aec423c2a (2023-04-01 10:41 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_IMAGE_THREADS = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions