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

{.experimental: "dotOperators".} not needed for template .(a, b), violating spec #13034

Open
timotheecour opened this issue Jan 4, 2020 · 1 comment

Comments

@timotheecour
Copy link
Member

timotheecour commented Jan 4, 2020

spec says {.experimental: "dotOperators".} is needed for dot operators, regardless of template vs macro.
current implementation differs, allowing template without {.experimental: "dotOperators".} (but agrees for macro)

Example

template `.`*(a, b: float) = echo "ok1"
{.push experimental: "dotOperators".}
macro `.`*(a, b: int) = echo "ok2"
{.pop.}

Current Output

compiles

Expected Output

Error: the overloaded . operator has to be enabled with {.experimental: "dotOperators".}

Additional Information

@timotheecour timotheecour changed the title {.experimental: "dotOperators".} not needed for template .(a, b), violating spec [minor] {.experimental: "dotOperators".} not needed for template .(a, b), violating spec Jan 4, 2020
@metagn
Copy link
Collaborator

metagn commented Feb 3, 2021

Same for callOperator. A big problem is these templates do actually work without experimental switch.

template `()`(a, b) = discard a + b

1(3)

Compiles. Same for push experimental/pop:

import macros

{.push experimental: "callOperator".}

macro `()`(a, b): untyped =
  result = infix(a, "+", b)

{.pop.}

echo 1(3)

@timotheecour timotheecour changed the title [minor] {.experimental: "dotOperators".} not needed for template .(a, b), violating spec {.experimental: "dotOperators".} not needed for template .(a, b), violating spec Feb 3, 2021
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.

2 participants