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

fix #20588 #21101

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3024,6 +3024,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit:
# check if it is an expression macro:
checkMinSonsLen(n, 1, c.config)
if n[0].kind == nkIdent and n[0].ident.id == ord(wAuto):
Copy link
Member

@Araq Araq Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't know at this point that auto was not redefined to be a proc overriding system.auto. Stop hacking special cases into the compiler. This a fix for semConv and it needs to check for more than just auto. For example untyped(4) or typed("abc) are likewise illegal constructs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow,I debug into serveral places haven't found it goes to semConv, I'll create a fix in next PR.

localError(c.config, n[0].info, "invalid call '$1'" % n[0].ident.s)
#when defined(nimsuggest):
# if gIdeCmd == ideCon and c.config.m.trackPos == n.info: suggestExprNoCheck(c, n)
let mode = if nfDotField in n.flags: {} else: {checkUndeclared}
Expand Down
23 changes: 23 additions & 0 deletions tests/arc/t20588.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
discard """
action: reject
nimout: '''
t20588.nim(21, 37) Error: invalid call 'auto'
'''
"""













func hakunaMatata[N, D](n: N, d: D): auto =
if d.float > 0: (n/d) else: 0.0.auto

discard hakunaMatata(42.0, 0.42)