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

Feature request: Constant-fold keyword arguments somehow #265

Closed
jakobnissen opened this issue Sep 29, 2021 · 3 comments
Closed

Feature request: Constant-fold keyword arguments somehow #265

jakobnissen opened this issue Sep 29, 2021 · 3 comments

Comments

@jakobnissen
Copy link
Contributor

jakobnissen commented Sep 29, 2021

Minimal example

julia> function foo(x::Integer, y::Bool=(x isa Int))
           if y
               x * "string"
           else
               x + one(x)
           end
       end
foo (generic function with 2 methods)

julia> @report_call foo(0x01)
═════ 1 possible error found ═════
┌ @ REPL[4]:2 #self#(x, Main.isa(x, Main.Int))
│┌ @ REPL[4]:3 Main.*(x, "string")
││ no matching method found for call signature (Tuple{typeof(*), UInt8, String}): Main.*(x::UInt8, "string")
│└─────────────

The error showed can in fact never happen, since in the call f(0x01), y statically should resolve to false.
I have no idea whether this kind of constant prop is feasible, either in Julia's compiler itself, or in JET.

This is on Julia 1.7-rc1.

@jakobnissen
Copy link
Contributor Author

jakobnissen commented Sep 29, 2021

Okay, I just now realized that my minimal example doesn't work! Let me close until I fix it
Updated example

@jakobnissen
Copy link
Contributor Author

It's in Base Julia: JuliaLang/julia#42449

@aviatesk
Copy link
Owner

Fixed by JuliaLang/julia#42529.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants