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

Very odd behaviour with return value. #12726

Closed
fcard opened this issue Aug 21, 2015 · 4 comments
Closed

Very odd behaviour with return value. #12726

fcard opened this issue Aug 21, 2015 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@fcard
Copy link
Contributor

fcard commented Aug 21, 2015

Sorry for the undescriptive title but I don't understand what's happening here at all.

I was trying to do the llvm Kaleidoscope tutorial in julia and in the middle of writing the parser I was met with a very confusing behaviour. Here is the smallest code I could reproduce the problem with (sorry if it's still too big). What happens seems to change, sometimes it crashes, sometimes things like this happen:

julia> include("c:/github/kaleidoscope/src/old/error_test.jl")
WARNING: replacing module ErrorTest
expr
primary 1
primary 4
identifier 1
args
expr
primary 1
primary 2
Should return: ErrorTest.AST.Numeric{Int64}(1)
EX: args
TYPE: args
ERROR: LoadError: MethodError: `convert` has no method matching convert(::Type{ErrorTest.AST.Expression}, ::ASCIIString)
This may have arisen from a call to the constructor ErrorTest.AST.Expression(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)
 in push! at array.jl:419
 in parse_args! at c:\github\kaleidoscope\src\old\error_test.jl:98
 in parse_identifier! at c:\github\kaleidoscope\src\old\error_test.jl:82
 in parse_primary! at c:\github\kaleidoscope\src\old\error_test.jl:72
 in parse_expr! at c:\github\kaleidoscope\src\old\error_test.jl:53
 in include at boot.jl:259
 in include_from_node1 at loading.jl:266
while loading c:\github\kaleidoscope\src\old\error_test.jl, in expression starting on line 115

expr through primary 2 are the functions being called, Should return is the value that should be returned to here, EX is the value actually returned, and TYPE is the type of the value, and somehow they're the same...? A few times EX was blank and julia crashes before TYPE is printed, but I couldn't reproduce that anymore.

Other inputs to parse_expr! seemed to work fine. "f()" works, "1" works, "x" works, only when it's called from within parse_args! does this happen.

I tried this both on linux and windows, and on 0.4 and 0.3, and the same thing happened.

For 0.4 I am using:

Version 0.4.0-dev+6859 (2015-08-20 19:38 UTC)
Commit 92ddae7 (0 days old master)

Am I missing something obvious? I really don't understand this.

@vtjnash
Copy link
Member

vtjnash commented Aug 21, 2015

from the code_typed, this looks a lot like #9770

@ViralBShah
Copy link
Member

Is this a bug we can fix for 0.4 and perhaps even backport?

@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Sep 17, 2015
@vtjnash
Copy link
Member

vtjnash commented Mar 26, 2016

fixed by #15300

@vtjnash vtjnash closed this as completed Mar 26, 2016
@fcard
Copy link
Contributor Author

fcard commented Mar 26, 2016

Yes!! Thank you very much for fixing this. You people are great! \o/ \o/ \o/

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
Projects
None yet
Development

No branches or pull requests

4 participants