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

Error: internal error: getTypeDescAux(tyFromExpr) when using auto + arc, works with refc #20588

Closed
arkanoid87 opened this issue Oct 18, 2022 · 4 comments · Fixed by #21104
Closed

Comments

@arkanoid87
Copy link
Contributor

arkanoid87 commented Oct 18, 2022

What happened?

# works with --gc:refc
# Error: internal error: getTypeDescAux(tyFromExpr) with --gc:arc

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

echo hakunaMatata(42.0, 0.42)

Nim Version

Nim Compiler Version 1.6.8 [Linux: amd64]
Compiled at 2022-09-27
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: c9f46ca8c9eeca8b5f68591b1abe14b962f80a4c
active boot switches: -d:release

Current Standard Output Logs

Error: internal error: getTypeDescAux(tyFromExpr)
No stack traceback available

Expected Standard Output Logs

100.0

Possible Solution

No response

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Nov 10, 2022

Compiles with 0.0.auto -> 0.0. Don't know what 0.0.auto is supposed to mean, it's not needed as far as I can tell:

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

echo hakunaMatata(42.0, 0.42).type # float
echo hakunaMatata(42f32, 3f32).type # float32

@bung87
Copy link
Collaborator

bung87 commented Dec 14, 2022

where the 0.0.auto goes in compiler? from my view auto is not suitable for a dotcall

@Vindaar
Copy link
Contributor

Vindaar commented Dec 14, 2022

where the 0.0.auto goes in compiler? from my view auto is not suitable for a dotcall

I would assume the symbol auto will be mapped to an implicit generic. Therefore the dot call for 0.0.auto just converts the literal to the implicit generic that auto was determined to be.

edit: I mean that's what I would understand the syntax to imply.

@bung87
Copy link
Collaborator

bung87 commented Dec 14, 2022

I debug in serveral places, in the end I start from semIf , found it's

proc semExprBranch(c: PContext, n: PNode; flags: TExprFlags = {}; expectedType: PType = nil): PNode =
  result = semExpr(c, n, flags, expectedType)
  echo result.typ

outputs typeof(auto(0.0))

bung87 added a commit to bung87/Nim that referenced this issue Dec 15, 2022
@bung87 bung87 mentioned this issue Dec 15, 2022
bung87 added a commit to bung87/Nim that referenced this issue Dec 15, 2022
@bung87 bung87 mentioned this issue Dec 15, 2022
bung87 added a commit to bung87/Nim that referenced this issue Dec 15, 2022
bung87 added a commit to bung87/Nim that referenced this issue Dec 15, 2022
Araq pushed a commit that referenced this issue Dec 15, 2022
survivorm pushed a commit to survivorm/Nim that referenced this issue Feb 28, 2023
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
narimiran pushed a commit that referenced this issue Apr 26, 2023
(cherry picked from commit 8054be6)
bung87 added a commit to bung87/Nim that referenced this issue Jul 29, 2023
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.

5 participants