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

Local variables in Macro defining abstract type #28593

Closed
nignatiadis opened this issue Aug 11, 2018 · 0 comments
Closed

Local variables in Macro defining abstract type #28593

nignatiadis opened this issue Aug 11, 2018 · 0 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior macros @macros

Comments

@nignatiadis
Copy link

Consider the following two macros for defining parametric concrete or abstract types:

macro m1()
    quote
        abstract type A{S<:Real, V<:AbstractVector{S}} end
    end
end

macro m2()
    quote
        struct A{S<:Real, V<:AbstractVector{S}} end
    end
end

While they are very similar, their behavior appears to be inconsistent:

@macroexpand @m1

quote
#= REPL[17]:3 =#
abstract type (Main.A){Main.S <: Main.Real, Main.V <: (Main.AbstractVector){Main.S}} end
end

@macroexpand @m2

quote
#= REPL[18]:3 =#
struct A{#1#S <: Main.Real, #2#V <: (Main.AbstractVector){#1#S}}
#= REPL[18]:3 =#
end
end

Below the versioinfo which is 0.7, but @mauro3 (who wrote the above minimal example) reproduced this on 1.0 as well.

Julia Version 0.7.0
Commit a4cb80f (2018-08-08 06:46 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

@JeffBezanson JeffBezanson self-assigned this Aug 11, 2018
@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior macros @macros labels Aug 11, 2018
KristofferC pushed a commit that referenced this issue Aug 24, 2018
KristofferC pushed a commit that referenced this issue Sep 8, 2018
KristofferC pushed a commit that referenced this issue Sep 8, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior macros @macros
Projects
None yet
Development

No branches or pull requests

2 participants