Skip to content

Error with optional argument in anonymous function defined in macro #36272

@zsunberg

Description

@zsunberg

In Julia 1.5.0 beta 1, the following fails:

macro m()
    :((a, b=1) -> a*b)
end
@m()(1)

with

ERROR: UndefVarError: b not defined
Stacktrace:
 [1] (::var"#1#2")(::Int64, ::Int64) at ./REPL[1]:3 (repeats 2 times)
 [2] top-level scope at REPL[1]:3

The reason I want to do this is here: https://github.com/JuliaPOMDP/POMDPs.jl/blob/609fe87094d4b1b01993deb0514565450266547f/src/generative.jl#L189. A workaround is to name the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions