Skip to content

New type system: stackoverflow when defining method #20103

Closed
@mauro3

Description

I'm pretty sure this only showed up after the #18457 merge (maybe add to list in #19998):

    _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-dev.2153 (2017-01-18 05:52 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit b8971ea4f* (0 days old master)
|__/                   |  x86_64-pc-linux-gnu

julia> immutable TT{X,Y} end

julia> f{X,Y}(::Type{TT{X,Y}},x::X,y::Y) = 1
f (generic function with 1 method)

julia> f{X}(::Type{TT{X,X}},x::X) = 100
ERROR: StackOverflowError:

julia> f(TT{Int,Int},1,2)
1

julia> f(TT{Int,Int},1) # it still works fine!
100

julia> methods(f)
# 2 methods for generic function "f":
f{X}(::Type{TT{X,X}}, x::X) in Main at REPL[3]:1
f{X,Y}(::Type{TT{X,Y}}, x::X, y::Y) in Main at REPL[2]:1

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviortypes and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions