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

Typed syntax output showing type unstable result as type stable? #599

Open
fingolfin opened this issue Sep 18, 2024 · 0 comments
Open

Typed syntax output showing type unstable result as type stable? #599

fingolfin opened this issue Sep 18, 2024 · 0 comments
Labels
bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage

Comments

@fingolfin
Copy link
Contributor

Consider this example:

function qux(x)
    v = []
    push!(v, x)
    return sum(v)
end;

function foo(a)
    function bar(x)
        qux(a)  # note reference to `a`
    end
    return bar(a)
end;

The first function qux is type unstable version of identity.

If I then @descend foo(1) and then descend into bar, I see this:

(::var"#bar#13")(x) @ Main REPL[64]:2
2 function bar(x::Int64)::Any
3             qux(a)::Int64
4     end
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
 • %2 = qux(::Int64)::Any
   ↩

Unfortunately I can't show color here, so I also made a screenshot:

bad-cthulhu

Note the contradictory output in bar: first it says that it has return type Any (correct). But then it says qux(a) has return type Int64 which is false. At the end it again correctly says %2 = qux(::Int64)::Any.

To me this look like a problem with printing the typed syntax tree. Maybe the ::Int64 should really be attached to the a (which comes from the outer function foo)?

Note that the issue goes away if I change qux(a) to e.g. qux(x) in the code.

@simeonschaub simeonschaub added bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage
Projects
None yet
Development

No branches or pull requests

2 participants