Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behavior of local functions is incorrect in v0.5 #18359

Closed
josefsachsconning opened this issue Sep 5, 2016 · 1 comment
Closed

behavior of local functions is incorrect in v0.5 #18359

josefsachsconning opened this issue Sep 5, 2016 · 1 comment

Comments

@josefsachsconning
Copy link
Contributor

I don't see an explanation in NEWS.md for this change in behavior, so I am considering it a bug.

C:\>julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.5 (2016-03-18 00:58 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-w64-mingw32

julia> function foo(val::Int64)
           if val == 1
               function bar()
                   return 100
               end
           elseif val == 2
               function bar()
                   return 200
               end
           end
           return bar()
       end
foo (generic function with 1 method)

julia> foo(1)
100

julia> foo(2)
200

julia> exit()

C:\>"C:\Program Files\Julia-0.5.0-rc3\bin\julia.exe"
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |  x86_64-w64-mingw32

julia> function foo(val::Int64)
           if val == 1
               function bar()
                   return 100
               end
           elseif val == 2
               function bar()
                   return 200
               end
           end
           return bar()
       end
WARNING: Method definition bar() in module Main at REPL[1]:4 overwritten at REPL[1]:8.
foo (generic function with 1 method)

julia> foo(1)
200

julia> foo(2)
200
@cstjean
Copy link
Contributor

cstjean commented Sep 5, 2016

It's #15602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants