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

(;) returns nothing rather than empty named tuple #30115

Closed
piever opened this issue Nov 21, 2018 · 12 comments · Fixed by #34557
Closed

(;) returns nothing rather than empty named tuple #30115

piever opened this issue Nov 21, 2018 · 12 comments · Fixed by #34557
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior minor change Marginal behavior change acceptable for a minor release needs decision A decision on this change is needed parser Language parsing and surface syntax
Milestone

Comments

@piever
Copy link
Contributor

piever commented Nov 21, 2018

Intuitively I would have imagined that (;) would be the syntax for the empty NamedTuple, whereas it returns nothing instead. After posting it on slack it seems that the rationale is that it is parsing as a concatenation of expressions. For example (1;) returns 1, so (;) should return the value of the first expression which is nothing.

I'm not sure which is more intuitive but maybe it could be changed to return NamedTuple(). The change in technically breaking though I imagine in practice very little code will rely on (;) === nothing

@StefanKarpinski StefanKarpinski added the parser Language parsing and surface syntax label Nov 21, 2018
@StefanKarpinski StefanKarpinski added minor change Marginal behavior change acceptable for a minor release bug Indicates an unexpected problem or unintended behavior labels Nov 21, 2018
@StefanKarpinski
Copy link
Member

We should definitely fix this since the empty named tuple is something that it's useful to have syntax for whereas having (;) as a confusing syntax for nothing is distinctly non-useful.

@JeffBezanson
Copy link
Member

Used to be a syntax error, then from what I can tell this "feature" was "added" in v0.5 :) Probably best to make it an error again in 1.1?

@StefanKarpinski
Copy link
Member

Is the plan to make it an error and later use if for an empty named tuple? Or leave it as an error?

@JeffBezanson
Copy link
Member

I'm not sure; I guess it's (slightly) breaking either way, so maybe it's equally good/bad to just switch it directly to an empty named tuple?

@StefanKarpinski
Copy link
Member

so maybe it's equally good/bad to just switch it directly to an empty named tuple?

👍 yes, I think that's the way to go.

@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Nov 29, 2018
@JeffBezanson JeffBezanson added this to the 1.x milestone Dec 6, 2018
@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Dec 6, 2018
@JeffBezanson
Copy link
Member

Triage is ok with that.

@JeffBezanson
Copy link
Member

There is some package code (very little) that uses :(;) in macros to make an empty block expression.

@StefanKarpinski
Copy link
Member

Triage has decided to make (;) an error for now.

@JeffBezanson JeffBezanson added the needs decision A decision on this change is needed label May 8, 2019
@StefanKarpinski
Copy link
Member

We never did end up doing anything about this, did we?

@JeffBezanson
Copy link
Member

It doesn't seem too important. I can make a branch that turns it into an error though. MacroTools changed its use of it already, so it might be ok.

@JeffBezanson
Copy link
Member

Here's something I don't think came up: how to parse (;;), (;;;) etc? Error? Still as an empty block?

JeffBezanson added a commit that referenced this issue Dec 6, 2019
@StefanKarpinski
Copy link
Member

As 3- and 4-dimensional tuples, obviously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior minor change Marginal behavior change acceptable for a minor release needs decision A decision on this change is needed parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants