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

Range types don't work with BackwardsIndex (and possibly others) #13618

Closed
PMunch opened this issue Mar 10, 2020 · 3 comments · Fixed by #20734
Closed

Range types don't work with BackwardsIndex (and possibly others) #13618

PMunch opened this issue Mar 10, 2020 · 3 comments · Fixed by #20734

Comments

@PMunch
Copy link
Contributor

PMunch commented Mar 10, 2020

I was trying to combine the two [] procedures in the deque module, one that takes Natural and one that takes BackwardsIndex. When I changed the type to Natural or BacwardsIndex and added a when switch in the body of the procedure it stopped accepting integers.

Example

proc test(x: Natural or BackwardsIndex): int =
  int(x)
  
echo test(^1) # This works
echo test(1)  # This doesn't

Current Output

Error: type mismatch: got <int literal(1)>
but expected one of: 
proc test(x: Natural or BackwardsIndex): int
  first type mismatch at position: 1
  required type for x: Natural or BackwardsIndex
  but expression '1' is of type: int literal(1)

expression: test(1)

Expected Output

1
1
@PMunch
Copy link
Contributor Author

PMunch commented Mar 10, 2020

Changes the Natural to an int makes this example work fine.

@krux02
Copy link
Contributor

krux02 commented Mar 10, 2020

probably related: #7265

@Clyybber
Copy link
Contributor

Clyybber commented Mar 10, 2020

Not really related I think. I think this is a sigmatch bug.

ringabout added a commit that referenced this issue Nov 2, 2022
ringabout added a commit that referenced this issue Nov 2, 2022
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
bung87 pushed 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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants