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

Returning tuple literal in proc with tuple return type gives compiler error #18826

Closed
ho0ber opened this issue Sep 9, 2021 · 0 comments · Fixed by #18827
Closed

Returning tuple literal in proc with tuple return type gives compiler error #18826

ho0ber opened this issue Sep 9, 2021 · 0 comments · Fixed by #18827

Comments

@ho0ber
Copy link

ho0ber commented Sep 9, 2021

Returning a tuple literal or a constructed tuple from a proc gives Error: no tuple type for constructor at compile time.

Example

proc two_numbers(): tuple =
  return (1,2)

echo two_numbers()

Current Output

Hint: used config file '/usr/local/Cellar/nim/1.4.8/nim/config/nim.cfg' [Conf]
Hint: used config file '/usr/local/Cellar/nim/1.4.8/nim/config/config.nims' [Conf]
....
/Users/scolburn/two_numbers.nim(4, 17) template/generic instantiation of `two_numbers` from here
/Users/scolburn/two_numbers.nim(2, 10) Error: no tuple type for constructor

I was unable to compile nim from git head to test with that, sorry.

Expected Output

(1, 2)

Possible Solution

Unknown; I'm a Nim beginner.

Additional Information

Workarounds for now:

proc two_numbers(): auto =
  return (1,2)

echo two_numbers()
proc two_numbers(): tuple =
  let x = (1,2)
  return x

echo two_numbers()
$ nim -v
Nim Compiler Version 1.4.8 [MacOSX: amd64]
Compiled at 2021-05-25
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release -d:nimUseLinenoise
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.

1 participant