Skip to content

UndefVarError when trying to use parametric function expression #45506

@nsajko

Description

@nsajko

No replies on discourse, so I guess this indeed is a bug.

Suppose we have this:

SomeType = Tuple{Int8, Int16}
f(::Type{Tuple{A, B}}) where {A <: Any, B <: Any} = B

If we now do f(SomeType), we get Int16 in return as expected.

The following however, results in ERROR: UndefVarError: B not defined:

(function(::Type{Tuple{A, B}}) where {A <: Any, B <: Any}
   B
 end)(SomeType)

versioninfo() output: (1.7.3 behaves the same in this case)

Julia Version 1.8.0-beta3
Commit 3e092a2521 (2022-03-29 15:42 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 1 on 8 virtual cores
Environment:
  LD_PRELOAD = /usr/lib/libswmhack.so.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorparserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions