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

mk_init_singleton failed when using default constructors to initialize non-trivial fields #16

Open
thautwarm opened this issue Nov 21, 2024 · 0 comments

Comments

@thautwarm
Copy link
Member

MWE:

using ObjectOriented

@oodef struct WebSocketClient1
    url::String
    running:: Ref{Bool}
end

@oodef mutable struct ClientConnect1
    client::WebSocketClient1

    function startConnect1(self,url)
        running = Ref{Bool}(true)
        self.client = WebSocketClient1(url,running)
    end
end


client = ClientConnect1()
client.startConnect1("aaaaa")

Exception:

ERROR: LoadError: ArgumentError: type does not have a definite number of fields
Stacktrace:
  [1] fieldcount(t::Any)
    @ Base .\reflection.jl:814
  [2] fieldtypes(T::Type)
    @ Base .\reflection.jl:841
  [3] mk_init_singleton(t::Any)
    @ ObjectOriented.RunTime C:\Users\Taine\.julia\packages\ObjectOriented\MfFaY\src\runtime.jl:152
  [4] map(f::typeof(ObjectOriented.RunTime.mk_init_singleton), t::Tuple{DataType, DataType})
    @ Base .\tuple.jl:274
  [5] mk_init_singleton(t::Any)
    @ ObjectOriented.RunTime C:\Users\Taine\.julia\packages\ObjectOriented\MfFaY\src\runtime.jl:152
  [6] _construct(type_default_initializers::Type, T::Type, args::Tuple{})
    @ ObjectOriented.RunTime C:\Users\Taine\.julia\packages\ObjectOriented\MfFaY\src\runtime.jl:203
  [7] #s15#4
    @ C:\Users\Taine\.julia\packages\ObjectOriented\MfFaY\src\runtime.jl:213 [inlined]
  [8] var"#s15#4"(T::Any, ::Any, default_initializers::Any, #unused#::Any, args::Any)
    @ ObjectOriented.RunTime .\none:0
  [9] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core .\boot.jl:602
 [10] ClientConnect1()
    ...

The generated function stub is trying to analyze the field count of Ref{Bool}.

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

1 participant