gara icon indicating copy to clipboard operation
gara copied to clipboard

tuple length matching problems.

Open krux02 opened this issue 5 years ago • 0 comments

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

krux02 avatar Mar 29 '20 13:03 krux02