Giter VIP home page Giter VIP logo

Comments (2)

aviatesk avatar aviatesk commented on August 25, 2024

Hi, actually this error is because of the abstract interpretation, not a missing concretization.
(rather, type aliases are always concretized, and so don't need to specify concretization_patterns for this case)

The analysis report comes from the analyze_from_definitions configuration.
struct definition internally defines its constructor like below:

julia> JET.@lwr struct Foo
           x::MyType
       end
:($(Expr(:thunk, CodeInfo(
     @ none within `top-level scope'
1 ──       global Foo
│          const Foo
│    %3  = Core.svec()
│    %4  = Core.svec(:x)
│          #217#Foo = Core._structtype(Main, :Foo, %3, %4, false, 1)
│          Core._setsuper!(#217#Foo, Core.Any)
│    %7  = $(Expr(:isdefined, :Foo))
└───       goto #6 if not %7
2 ── %9  = Foo
│    %10 = Core._equiv_typedef(%9, #217#Foo)
└───       goto #4 if not %10
3 ──       #217#Foo = %9
└───       goto #5
4 ──       Foo = #217#Foo
5 ┄─       goto #7
6 ──       Foo = #217#Foo
7 ┄─ %17 = #217#Foo
│    %18 = Core.svec(MyType)
│          Core._typebody!(%17, %18)
│          global Foo
│    %21 = Core.Any === MyType
└───       goto #9 if not %21
8 ──       goto #10
9 ──       $(Expr(:method, :Foo))
│    %25 = Core.Typeof(Foo)
│    %26 = Core.svec(%25, MyType)
│    %27 = Core.svec()
│    %28 = Core.svec(%26, %27, $(QuoteNode(:(#= none:2 =#))))
└───       $(Expr(:method, :Foo, :(%28), CodeInfo(
    @ none:2 within `none'
1 ─ %1 = %new(Foo, x)
└──      return %1
)))
10 ┄       $(Expr(:method, :Foo))
│    %31 = Core.Typeof(Foo)
│    %32 = Core.svec(%31, Core.Any)
│    %33 = Core.svec()
│    %34 = Core.svec(%32, %33, $(QuoteNode(:(#= none:2 =#))))
│          $(Expr(:method, :Foo, :(%34), CodeInfo(
    @ none:2 within `none'
1%1 = Foo
│   %2 = Core.fieldtype(%1, 1)
│   %3 = Base.convert(%2, x)
│   %4 = %new(%1, %3)
└──      return %4
)))
└───       return nothing
))))

and the error is reported at Base.convert(%2::AbstractVector{<:AbstractString}, x::Any).

That said, this false positive frequently happens when using analyze_from_definitions=true, and so I think JET needs to fix this somehow.

from jet.jl.

aviatesk avatar aviatesk commented on August 25, 2024

Easy workaround for now is to set max_methods=1 configuration: report_file("main.jl"; analyze_from_definitions = true, concretization_patterns = [:(MyType = x_)], max_methods=1)

I'm considering making this default though.

from jet.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.