Skip to content

scope of identifier names in lowered syntax forms #25947

Closed
@krrutkow

Description

Is this behavior intended?

julia> f(c) = 1:5 ;

julia> f(0)
1:5

julia> g(colon) = 1:5 ;

julia> g(0)
ERROR: MethodError: objects of type Int64 are not callable
Stacktrace:
 [1] g(::Int64) at ./REPL[3]:1
 [2] top-level scope

If so, is it documented anywhere what variable/function names could change behavior, or could the names used by changed to be more "internal-looking" (e.g. __colon__ instead)?

I can see how the behavior is a potentially useful feature:

julia> function f()
           colon = function (args...) ; println("args: ", join([args...], ' ')) ; Base.colon(args...) ; end
           1:5
       end
f (generic function with 1 method)

julia> f()
args: 1 5
1:5

Metadata

Assignees

Labels

breakingThis change will break codecompiler:loweringSyntax lowering (compiler front end, 2nd stage)parserLanguage parsing and surface syntax

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions