This code to "uncurry" a two parameter function is almost certainly incorrect 
Nim, but on macOS with the `devel` compiler it causes a `SIGSEGV: Illegal 
storage access. (Attempt to read from nil?)` error.
    
    
    func uncurry*[T, U, V](fn: proc (x: T, y: U): V {.nimcall}): (proc (xs: (T, 
U)): V {.nimcall.}) =
      proc foo(xs: (T, U)): V {.nimcall.} = fn(xs[0], xs[1])
    
    func add(a: int, b: int): int = a + b
    
    echo (uncurry(add))((1,2))
    
    
    Run

If any can confirm this is a compiler issue I'll open a GitHub issue.
    
    
    $ nim --version
    Nim Compiler Version 1.5.1 [MacOSX: arm64]
    Compiled at 2021-07-22
    Copyright (c) 2006-2021 by Andreas Rumpf
    
    git hash: 58e27ebd4a16ca9f2ba24826d7162384d5321101
    active boot switches: -d:release
    
    
    Run

Reply via email to