Skip to content

Parsing issue for composed return value with => #25391

Description

@KlausC
julia> f1() = begin 0:-1, ""=>"" end;

julia> f2() = begin (0:-1, ""=>"") end;

I expected the same return type for both functions, but:

julia> typeof(f1())
Pair{Tuple{UnitRange{Int64},String},String}

julia> typeof(f2())
Tuple{UnitRange{Int64},Pair{String,String}}

julia> typeof((0:-1, ""=>""))
Tuple{UnitRange{Int64},Pair{String,String}}

julia> typeof(((0:-1, ""=>"")))
Tuple{UnitRange{Int64},Pair{String,String}}

julia> typeof(((0:-1, "")=>""))
Pair{Tuple{UnitRange{Int64},String},String}

It looks like the comma "operator" in a,b has precedence before the => operator.
IMO that is not to be expected and a parsing issue, because the consequence is, that parens
around an expression can change the meaning.
With my restricted insight, I cannot imagine a reason for comma needing a high precedence, when
it appears outside a parenthesized list.

PS: its the same with assignments x1 = 0:-1, ""=>"" etc.

Metadata

Metadata

Assignees

Labels

parserLanguage parsing and surface syntax

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions