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

ERROR: error compiling anonymous: unsupported or misplaced expression export in function anonymous #8051

Closed
kmsquire opened this issue Aug 19, 2014 · 4 comments

Comments

@kmsquire
Copy link
Member

I receive the error in the subject when I attempt to conditionally compile the source code below.

However, if I remove ;flip=false from the definition of play, everything compiles and works fine, including the export line.

This seems inconsistent to me, although I'd be happy with an explanation and/or a workaround.

try
    if isa(Main.ImageView, Module)
        # Define read and retrieve for Images
        global playvideo, play
        export playvideo, play

        function play(f; flip=false)
            img = read(f, Main.Images.Image)
            flip && (img = fliplr(img))
            canvas, _ = Main.ImageView.view(img)

            while !eof(f)
                read!(f, img)
                flip && (img = fliplr(img))
                Main.ImageView.view(canvas, img)
                sleep(1/f.framerate)
            end
        end

        function playvideo(video)
            f = VideoIO.openvideo(video)
            play(f)
        end
    end
end

For reference, this is from here.

I'm on a version of master compiled today:

julia> versioninfo()
Julia Version 0.4.0-dev+236
Commit 93d73e7* (2014-08-19 03:23 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
@JeffBezanson
Copy link
Member

Very related: #2586 #6195 #5352

There are all kinds of issues with putting top-level expressions in strange places.

@kmsquire
Copy link
Member Author

Thanks, Jeff. I am looking forward to #6195 or some variation thereof. Cheers!

@hayd
Copy link
Member

hayd commented Mar 16, 2015

I get this error when trying to do conditionally import Base.Markdown in Markdown.jl:

module Markdown
if VERSION > v"0.4-"
    for f in names(Base.Markdown, true, false)
       eval(Expr(:export, f))
    end
else
# rest of code

Which doesn't quite work without the conditional anyways!

@kmsquire
Copy link
Member Author

Addressed by using Requires. See #2025 (comment) and below for discussion.

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

3 participants