Skip to content

Strange dispatch with @pure #20704

@andyferris

Description

@andyferris

I was trying to understand the behavior of @pure (as well as @generated) and how they relate to the recent fix to #265, and came across this strange case.

I'm not sure why the following code doesn't result in a missing method error on foo on the last line:

julia> foo(::Int) = 1
foo (generic function with 1 method)

julia> Base.@pure bar(x::ANY) = foo(x)
bar (generic function with 1 method)

julia> bar(42)
1

julia> bar(42.0)
1

The error is (correctly) present on Julia v0.5.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorcompiler:inferenceType inference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions