aiken-lang / aiken

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

Error: Unknown type #995

Closed invent360 closed 2 months ago

invent360 commented 2 months ago

What Git revision are you using?

aiken-lang/stdlib 1.9.0

What operating system are you using, and which version?

Describe what the problem is?

Following the hello world example.

use aiken/hash.{Blake2b_224, Hash}
use aiken/list
use aiken/transaction.{ScriptContext}
use aiken/transaction/credential.{VerificationKey}

type Datum {
  owner: Hash<Blake2b_224, VerificationKey>,
}

type Redeemer {
  msg: ByteArray,
}

validator {
  fn spend(datum: Datum, redeemer: Redeemer, context: ScriptContext) -> Bool {
    let must_say_hello = redeemer.msg == "Hello, World!"

    let must_be_signed =
      list.has(context.transaction.extra_signatories, datum.owner)

    must_say_hello && must_be_signed
  }
}

Even tried adding the following manually, to avail

use aiken/bytearray
use aiken/dict
use aiken/pairs

What should be the expected behavior?

the following commands should run without errors aiken check aiken build But i had the following errors

(base) ➜  helloworld aiken check
    Compiling katson95/helloworld 0.0.0 (/Users/<me>/helloworld)
    Compiling aiken-lang/stdlib 1.9.0 (/Users/<me>/helloworld/build/packages/aiken-lang-stdlib)
        Error aiken::check::unknown::type

  × While trying to make sense of your code...
  ╰─▶ I found a reference to an unknown type.

    ╭─[/Users/<me>/helloworld/build/packages/aiken-lang-stdlib/lib/aiken/dict.ak:29:1]
 29 │ pub opaque type Dict<key, value> {
 30 │   inner: Pairs<ByteArray, value>,
    ·          ───────────┬───────────
    ·                     ╰── unknown type
 31 │ }
    ╰────
  help: Did you forget to import it?

      Summary 1 error, 0 warnings
KtorZ commented 2 months ago

As mentioned in the compatibility matrix in the stdlib's README, you need to use a version of the compiler equal or higher than 1.0.28 to work with stdlib==1.9.0.

In all likelihood, you are not.

invent360 commented 2 months ago

you are right, i was using aiken v1.0.26-alpha+075668b sorry didn't check the matrix. I upgraded to aiken v1.0.31-alpha+unknown and it works now. thanks