aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
396 stars 82 forks source link

not implemented: MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z) #964

Open Fell-x27 opened 1 month ago

Fell-x27 commented 1 month ago

I've just replaced list.push with cons_list to check if it is more efficient, and then got the error:

   aiken::fatal::error
   Whoops! You found a bug in the Aiken compiler.

   Please report this error at https://github.com/aiken-lang/aiken/issues/new.
   In your bug report please provide the information below and if possible the code
   that produced it.

   Operating System: linux
   Architecture:     x86_64
   Version:          v1.0.29-alpha+16fb02e

   crates/aiken-lang/src/gen_uplc.rs:4517:25

       not implemented: MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z).

so...here I am :)

You can reproduce it with this snippet:

use aiken/list
use aiken/builtin

fn buggy(arg: List<Int>) -> List<Int> {
  let result =
    arg
      |> list.foldl([], fn(x, acc) { builtin.cons_list(x, acc) })
  result
}

fn not_buggy(arg: List<Int>) -> List<Int> {
  let result =
    arg
      |> list.foldl([], fn(x, acc) { list.push(acc, x) })
  result
}

test bug() {
  let a =
    [1, 2, 3, 4, 5]
  not_buggy(a) == buggy(a)
}
MicroProofs commented 1 month ago

The bracket operators are simply the cons_list under the hood. There is a type conversion that is necessary so that's why I blocked the builtin for now.