Skip to content

Support structs without fields? #4

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

Open
ericphanson opened this issue Sep 29, 2022 · 3 comments
Open

Support structs without fields? #4

ericphanson opened this issue Sep 29, 2022 · 3 comments

Comments

@ericphanson
Copy link

ericphanson commented Sep 29, 2022

E.g.

julia> @compactify begin
           @abstract struct AT end
           struct A <: AT end
           struct B <: AT end
           end
ERROR: LoadError: AssertionError: no getproperty matches?
Stacktrace:
 [1] _compactify(mod::Module, block::Expr; debug::Bool, show_methods::Bool)
   @ Unityper ~/.julia/packages/Unityper/vtKYP/src/compactify.jl:346
 [2] var"@compactify"(__source__::LineNumberNode, __module__::Module, exs::Vararg{Any})
   @ Unityper ~/.julia/packages/Unityper/vtKYP/src/compactify.jl:46
in expression starting at REPL[3]:1

If I remove the @assert expr !== ifold "no getproperty matches?" this seems to work but I'm not sure if there's some other issue.

@chriselrod
Copy link
Collaborator

What's the advantage over

@enum AT A B

?

@ericphanson
Copy link
Author

I think I wanted to do MasonProtter/SumTypes.jl#15 (comment) in UniTyper but couldn’t represent the empty object

@chriselrod
Copy link
Collaborator

A single empty should work?

julia> @compactify begin
                  @abstract struct AT end
                  struct A <: AT end
                  struct B <: AT; x::Int=0; end
                  end

I'd guess removing the @assert like you did shouldn't cause any problems.

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

2 participants