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

limit_type_size failure for Type{Type{..}} #40336

Closed
vtjnash opened this issue Apr 3, 2021 · 0 comments · Fixed by #40379
Closed

limit_type_size failure for Type{Type{..}} #40336

vtjnash opened this issue Apr 3, 2021 · 0 comments · Fixed by #40379
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference

Comments

@vtjnash
Copy link
Member

vtjnash commented Apr 3, 2021

julia> f(@nospecialize(t)) = f(Type{t})
f (generic function with 1 method)

julia> @code_typed f(Int)
ERROR: StackOverflowError:

So clearly this type-limit isn't working:

        if isType(t) # allow taking typeof as Type{...}, but ensure it doesn't start nesting
            tt = unwrap_unionall(t.parameters[1])
            if isa(tt, DataType) && !isType(tt)
                is_derived_type_from_any(tt, sources, depth) && return t
            end
        end

Reported by @aviatesk

@vtjnash vtjnash added bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference labels Apr 3, 2021
aviatesk added a commit to aviatesk/julia that referenced this issue Apr 4, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. AFAIU this should return `true`, and
the change will fix JuliaLang#40336.
vtjnash added a commit that referenced this issue Apr 6, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. Per comment there, this should return `true`,
but the code was ordered incorrect (it was also missing support for
Vararg, after the recent changes).

Fixes #40336

Co-authored-by: Shuhei Kadowaki <[email protected]>
vtjnash added a commit that referenced this issue Apr 9, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. Per comment there, this should return `true`,
but the code was ordered incorrect (it was also missing support for
Vararg, after the recent changes).

Fixes #40336

Co-authored-by: Shuhei Kadowaki <[email protected]>
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this issue May 4, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. Per comment there, this should return `true`,
but the code was ordered incorrect (it was also missing support for
Vararg, after the recent changes).

Fixes JuliaLang#40336

Co-authored-by: Shuhei Kadowaki <[email protected]>
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this issue May 9, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. Per comment there, this should return `true`,
but the code was ordered incorrect (it was also missing support for
Vararg, after the recent changes).

Fixes JuliaLang#40336

Co-authored-by: Shuhei Kadowaki <[email protected]>
aviatesk added a commit that referenced this issue May 28, 2021
Fixes the inference regression, while retaining the cases addressed by
<#40379>.

The same `Type`-name comparison pass (i.e. a branch of `isa(c, DataType) && t.name === c.name`)
can lead to more accurate result by recursive comparison than `isType`
check pass (i.e. a branch of `isType(t)`), and preferring the former
over the latter fixes the regression.

But just swapping the branch will lead to <#40336>,
and so this PR also implements additional check to make sure `type_more_complex`
still detects a single-level nesting correctly (especially, the `tt === c` parts).
aviatesk added a commit that referenced this issue May 31, 2021
Fixes the inference regression, while retaining the cases addressed by
<#40379>.

The same `Type`-name comparison pass (i.e. a branch of `isa(c, DataType) && t.name === c.name`)
can lead to more accurate result by recursive comparison than `isType`
check pass (i.e. a branch of `isType(t)`), and preferring the former
over the latter fixes the regression.

But just swapping the branch will lead to <#40336>,
and so this PR also implements additional check to make sure `type_more_complex`
still detects a single-level nesting correctly (especially, the `tt === c` parts).
johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
Previously `type_more_complex` returns `false` for `Type{Type{...}}`
compared against `Type{...}`. Per comment there, this should return `true`,
but the code was ordered incorrect (it was also missing support for
Vararg, after the recent changes).

Fixes JuliaLang#40336

Co-authored-by: Shuhei Kadowaki <[email protected]>
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 compiler:inference Type inference
Projects
None yet
1 participant