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

fix struct blocks #11

Closed t-bltg closed 1 year ago

t-bltg commented 1 year ago

Fix corner cases, where class declarations are generated by a macro (hence a block of expressions).

This is valid julia syntax, so it should be allowed (see the added test).

Without this PR, the added test fails with:

ERROR: LoadError: LoadError: unrecognised statement in TestBlockType definition: begin
    #= REPL[4]:3 =#
    a::Int
    #= REPL[4]:4 =#
    b::Nothing
end
thautwarm commented 1 year ago

I can confirm this is consistent to the vanilla Julia structs' behavior.

thautwarm commented 1 year ago

You might move the macro definition @gen outside the testset?

t-bltg commented 1 year ago

Sure, done in https://github.com/Suzhou-Tongyuan/ObjectOriented.jl/commit/7f006cdfe34944e378b8a9ca98982742367ac700.

I've also moved the struct outside, to respect the conventions used in runtests.jl.