8000 tuple length matching problems. · Issue #25 · alehander92/gara · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
tuple length matching problems. #25
Open
@krux02

Description

@krux02
import gara

proc mymain() =
  let a = ("a", "b", "c")
  match a:
    ("a",):
      echo a, " matches 1-tuple"
    ("a", "b"):
      echo a, " matches 2-tuple"
    ("a", "b", "c"):
      echo a, " matches 3-tuple"

mymain()

output:

("a", "b", "c") matches 2-tuple

expected output:

("a", "b", "c") matches 3-tuple

Writing a matcher that is too long for the tuple fails to compile.

import gara

proc mymain() =
  let a = ("a", "b", "c")

  match a:
    ("a",):
      echo a, " matches 1-tuple"
    ("a", "b"):
      echo a, " matches 2-tuple"
    ("a", "b", "c"):
      echo a, " matches 3-tuple"
    ("a", "b", "c", "d"):
      echo a, " mathces 4-tuple"

mymain()

output:

/home/arne/proj/nim/Nim/pkgstemp/gara/src/gara.nim(33, 15) Error: invalid index value for tuple subscript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0