Suzhou-Tongyuan / ObjectOriented.jl

Conventional object-oriented programming in Julia without breaking Julia's core design ideas
MIT License
88 stars 6 forks source link

parametric constructor warning #10

Closed t-bltg closed 7 months ago

t-bltg commented 1 year ago

The following leaves a warning, although the result is correct:

julia> @oodef struct Foo{F}
  x::F
  function new()
    @mk x = F(1)
  end
end
WARNING: method definition for Foo at REPL[4]:3 declares type variable F but does not use it.

julia> f = Foo{Float64}()
julia> f.x
1.0
thautwarm commented 7 months ago

This is generally not achievable due to the lack of scope analysis tool for Julia metaprogramming. Anyway, I created a partial fix for this at https://github.com/Suzhou-Tongyuan/ObjectOriented.jl/pull/14 .

Please comment if any idea.