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

short function syntax #8

Open
t-bltg opened this issue May 8, 2023 · 0 comments · May be fixed by #9
Open

short function syntax #8

t-bltg opened this issue May 8, 2023 · 0 comments · May be fixed by #9

Comments

@t-bltg
Copy link
Contributor

t-bltg commented May 8, 2023

In my codes, I use the

foo() = begin
end

convention instead of

function foo()
end

As a results, this fails:

julia> using ObjectOriented
julia> @oodef struct Foo
    new() = begin
       @mk
    end
end
ERROR: LoadError: MethodError: Cannot `convert` an object of type Expr to an object of type Symbol
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:205
  Symbol(::Any...) at strings/basic.jl:229
Stacktrace:
 [1] ObjectOriented.CompileTime.FieldInfo(ln::Any, name::Any, type::Any, defaultVal::Any)
   @ ObjectOriented.CompileTime [...]/.julia/packages/ObjectOriented/1M2LB/src/compile-time.reflection.jl:115
 [2] ObjectOriented.CompileTime.FieldInfo(; ln::Any, name::Any, type::Any, defaultVal::Any)
   @ ObjectOriented.CompileTime util.jl:453
 [3] parse_field_def(ln::LineNumberNode, f::Any; fallback::Nothing)
   @ ObjectOriented.CompileTime [...]/.julia/packages/ObjectOriented/1M2LB/src/compile-time.reflection.jl:254
 [4] parse_class_body!(ln::LineNumberNode, self::ObjectOriented.CompileTime.TypeDef, body::Any; preprocess::ObjectOriented.CompileTime.var"#preprocess#47"{Module})
   @ ObjectOriented.CompileTime [...]/.julia/packages/ObjectOriented/1M2LB/src/compile-time.reflection.jl:230
 [5] parse_class(ln::LineNumberNode, def::Any; preprocess::ObjectOriented.CompileTime.var"#preprocess#47"{Module})
   @ ObjectOriented.CompileTime [...]/.julia/packages/ObjectOriented/1M2LB/src/compile-time.reflection.jl:170
 [6] var"@oodef"(__source__::LineNumberNode, __module__::Module, ex::Any)
   @ ObjectOriented.CompileTime [...]/.julia/packages/ObjectOriented/1M2LB/src/compile-time.jl:21
in expression starting at REPL[4]:1

We hit this pattern matching:

:($n = $v) => FieldInfo(ln = ln, name = n, defaultVal = v)

@t-bltg t-bltg changed the title function syntax short function syntax May 8, 2023
@t-bltg t-bltg linked a pull request May 8, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant