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

Expand constants inside literals in macro calls #2423

Closed
jhass opened this issue Apr 6, 2016 · 1 comment · Fixed by #10819
Closed

Expand constants inside literals in macro calls #2423

jhass opened this issue Apr 6, 2016 · 1 comment · Fixed by #10819

Comments

@jhass
Copy link
Member

jhass commented Apr 6, 2016

Ref #2392 #2388

The following should expand the constant:

require "json"

ID_TYPE = {type: Int32, converter: ObscureApi}
class Foo
  JSON.mapping(
    id: {{ID_TYPE}},
    other: Stuff
  )
end

class Bar
  JSON.mapping(
    id: {{ID_TYPE}},
    different: Stuff
  )
end
@HertzDevil
Copy link
Contributor

HertzDevil commented Jun 13, 2021

I would consider this a bug. Only named arguments are not expanded:

macro foo(x0, x1, *xs, n0, n1, **ns)
  {% x0 %} # => 1
  {% x1 %} # => 2
  {% xs %} # => {3, 4}
  {% n0 %} # => {{ 5 }}
  {% n1 %} # => {{ 7 }}
  {% ns %} # => {n2: {{ 6 }}, n3: {{ 8 }}}
end

foo(
  {{ 1 }}, {{ 2 }}, {{ 3 }}, {{ 4 }},
  n0: {{ 5 }}, n2: {{ 6 }}, n1: {{ 7 }}, n3: {{ 8 }},
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants