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

nimsuggest: def result is incorrect when used on template without parentheses #24488

Open
doongjohn opened this issue Dec 1, 2024 · 0 comments

Comments

@doongjohn
Copy link

Description

def result is incorrect when used on template without parentheses

let num = 10

template sometemplate: auto = num + 1
echo sometemplate()
echo sometemplate

template varalias: auto = num
echo varalias()
echo varalias

Nim Version

Nim Compiler Version 2.2.1 [Windows: amd64]
Compiled at 2024-11-28
Copyright (c) 2006-2024 by Andreas Rumpf

active boot switches: -d:release

Current Output

echo sometemplate()
     ^ --> here (def is working as expected)
> def 4:5 
def     skTemplate      main.sometemplate       template (): auto       ...\main.nim        3       9       ""      100

echo sometemplate
     ^ --> here (def is not working as expected)
> def 5:5
def     skProc  system.`+`      proc (x: int, y: int): int{.noSideEffect, raises: <inferred> [].}       ...\nim\lib\system\arithmetics.nim   75      5       "Binary `+` operator for an integer."   100

echo varalias()
     ^ --> here (def is working as expected)
> def 8:5
def     skTemplate      main.varalias   template (): auto       ...\main.nim        7       9       ""      100

echo varalias
     ^ --> here (def is not working as expected)
> def 9:5 
def     skLet   main.num        int     ...\main.nim        1       4       ""      100

Expected Output

echo sometemplate
     ^ --> here
> def 5:5 
def     skTemplate      main.sometemplate       template (): auto       ...\main.nim        3       9       ""      100

echo varalias
     ^ --> here
> def 9:5
def     skTemplate      main.varalias   template (): auto       ...\main.nim        7       9       ""      100

Known Workarounds

No response

Additional Information

It works as expected in --v2 but not in v3, v4.

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

1 participant