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

typeintersect Vararg aborts #44735

Closed
vtjnash opened this issue Mar 24, 2022 · 7 comments
Closed

typeintersect Vararg aborts #44735

vtjnash opened this issue Mar 24, 2022 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Milestone

Comments

@vtjnash
Copy link
Member

vtjnash commented Mar 24, 2022

this is not good:

julia> typeintersect(Vararg{Int}, Int)
julia: /data/vtjnash/julia/src/subtype.c:1261: subtype: Assertion `!jl_is_vararg(x) && !jl_is_vararg(y)' failed.

signal (6): Aborted

and other mild oddities (I think these are correct, since they can appear as type parameters, they should be valid as arguments also)

julia> typeintersect(1, 2)
Union{}

julia> typeintersect(1, 1)
1

julia> typeintersect(1, Any)
1

julia> typeintersect(Any, 1)
1
@vtjnash vtjnash added the bug Indicates an unexpected problem or unintended behavior label Mar 24, 2022
@vtjnash vtjnash added this to the 1.8 milestone Mar 24, 2022
@vtjnash vtjnash added types and dispatch Types, subtyping and method dispatch regression Regression in behavior compared to a previous version labels Mar 24, 2022
@Keno
Copy link
Member

Keno commented Mar 24, 2022

Well, Vararg{Int} isn't really a type. We've been moving away from just allowing arbitrary values in typeintersect. I mean, it probably shouldn't abort, but passing in Vararg{Int} is probably a bug in the caller.

@aviatesk
Copy link
Member

Maybe we want to do some assertions on Julia level?

@Moelf
Copy link
Contributor

Moelf commented Mar 29, 2022

looks like it no longer crashes on master

julia> typeintersect(Vararg{Int}, Int)
Union{}

@aviatesk
Copy link
Member

You need to have assert build to repro this.

@Moelf
Copy link
Contributor

Moelf commented Mar 29, 2022

I see. as for adding checks on the Julia side, is this too naive/hacky?

function typeintersect(@nospecialize(a), @nospecialize(b))
    @_pure_meta
    if typeof(a) !== DataType
        throw(TypeError(:typeintersect, DataType, a))
    elseif typeof(b) !== DataType
        throw(TypeError(:typeintersect, DataType, b))
    end
    ccall(:jl_type_intersection, Any, (Any, Any), a, b)
emd

@JeffBezanson
Copy link
Member

Checking a isa Type might be ok.

@Moelf
Copy link
Contributor

Moelf commented Apr 5, 2022

😅 right; I see @aviatesk has done this on the C side in his branch so I won't make a PR.

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 regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants