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

can't build a tuple with static int element #10073

Closed
timotheecour opened this issue Dec 22, 2018 · 2 comments
Closed

can't build a tuple with static int element #10073

timotheecour opened this issue Dec 22, 2018 · 2 comments

Comments

@timotheecour
Copy link
Member

timotheecour commented Dec 22, 2018

can't build a tuple with static int element

Example

block:
  proc foo[N: static int](dims: array[N, int])=
    const N1 = N
    let temp = N # works
    let temp2 = (a:N) # Error: invalid type: 'static[int](2)' in this context: 'tuple[a: static[int](2)]' for let
    # let temp3 = (N, N) # ditto

  foo([1, 2])

Current Output

Error: invalid type: 'static[int](2)' in this context: 'tuple[a: static[int](2)]' for let

Expected Output

compiles because let temp = N works

@Araq
Copy link
Member

Araq commented Dec 22, 2018

But let temp = N strips away the static'ness. This is not a bug but static T has a fair share of terrible design choices.

@Araq Araq closed this as completed Dec 22, 2018
@timotheecour
Copy link
Member Author

timotheecour commented Dec 23, 2018

/cc @Araq
reopening because I really don't understand your analysis.
here's another example:

why would

  • let temp1 = N work
  • let temp2 = Foo(age: N) work
  • let temp3 = (age:N) not work? <- BUG

seems to me there's a bug in tuple construction; it should be have like the way object does in this case

when true:
  type Foo = object
    age: int
  proc foo[N: static int](dims: array[N, int])=
    const N1 = N
    let temp1 = N # works
    let temp2 = Foo(age: N)
    # let temp3 = (age:N) # uncomment gives: Error: invalid type: 'static[int](2)' in this context: 'tuple[age: static[int](2)]' for let
  foo([1, 2])

/cc @LemonBoy (because your fix in #9046 for #9043 added a test case that's blocking my PR #10070 ; and after reduction, I'm getting the bug mentioned in this issue)
/cc @krux02 because you were involved in #9043

@timotheecour timotheecour reopened this Dec 23, 2018
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 23, 2018
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 23, 2018
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 24, 2018
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 30, 2018
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 30, 2018
This reverts commit b3827d5.
zah added a commit that referenced this issue Jan 6, 2019
zah added a commit that referenced this issue Jan 6, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jan 7, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jan 7, 2019
This reverts commit b3827d5.
@Araq Araq closed this as completed in 87f8ec5 Jan 7, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jan 9, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jan 9, 2019
This reverts commit b3827d5.
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.

2 participants