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

1.+im returns a Complex{Int} #10920

Closed
mauro3 opened this issue Apr 21, 2015 · 10 comments
Closed

1.+im returns a Complex{Int} #10920

mauro3 opened this issue Apr 21, 2015 · 10 comments
Labels
parser Language parsing and surface syntax

Comments

@mauro3
Copy link
Contributor

mauro3 commented Apr 21, 2015

julia> typeof(1.+im)
Complex{Int64}

julia> typeof(1.)
Float64

julia> typeof(1+1.im)
Complex{Float64}

should be a Float64

@StefanKarpinski
Copy link
Member

This is parsed as 1 .+ im rather than 1. + im. So the title is a bit misleading.

@mauro3 mauro3 changed the title 1. + im is Complex{Int} 1. + im returns a Complex{Int} Apr 21, 2015
@mauro3
Copy link
Contributor Author

mauro3 commented Apr 21, 2015

I see the problem. Feel free to close if it cannot be resolved.

@StefanKarpinski
Copy link
Member

I wouldn't mind this being a warning or something.

@mbauman
Copy link
Member

mbauman commented Apr 21, 2015

Dup of #5246, which is nearly impossible to search for. But I'll leave this open for now.

Parser warnings are annoying since the REPL parses your statements twice, so they print twice. But maybe that can be fixed, too.

@JeffBezanson JeffBezanson changed the title 1. + im returns a Complex{Int} 1.+im returns a Complex{Int} Apr 21, 2015
@JeffBezanson
Copy link
Member

I don't really like giving a warning for this. It means you have to change your code if you want to remove the annoying message, so it might as well be an error if anything.

@kmsquire
Copy link
Member

Is it easy for the parser to error and give both possible parses for
situations like this?

On Tue, Apr 21, 2015 at 10:18 AM, Jeff Bezanson [email protected]
wrote:

I don't really like giving a warning for this. It means you have to change
your code if you want to remove the annoying message, so it might as well
be an error if anything.


Reply to this email directly or view it on GitHub
#10920 (comment).

@JeffBezanson
Copy link
Member

Yes I think it would be pretty easy to give an error.

@jiahao
Copy link
Member

jiahao commented Apr 21, 2015

+1 to parser error

Old crufty me is used to writing 2./x in C and Fortran to mean 2.0e0/x and this occasionally trips me up.

@ihnorton ihnorton added the parser Language parsing and surface syntax label Apr 23, 2015
@stevengj
Copy link
Member

+1 for parser error

jakebolewski added a commit that referenced this issue Jun 2, 2015
… operators

This *breaking* change throws a parser error asking the user to
disambiguate the parsing of a numeric literal and dot operator with no
whitespace in between.  We are consistent in how this is handled (always
favor the operator in parsing with no disambiguating whitespace), but
there was popular support that this should be special cased as it it
quite hard to track these subtle syntax errors down.

Closes #10920
jakebolewski added a commit that referenced this issue Jun 2, 2015
… operators

This *breaking* change throws a parser error asking the user to
disambiguate the parsing of a numeric literal and dot operator with no
whitespace in between.  We are consistent in how this is handled (always
favor the operator in parsing with no disambiguating whitespace), but
there was popular support that this should be special cased as it it
quite hard to track these subtle syntax errors down.

Closes #10920
@jakebolewski
Copy link
Member

See comments in #11529.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants