aiken-lang / aiken

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

Example build errors #925

Closed ross-spencer closed 2 months ago

ross-spencer commented 2 months ago

What Git revision are you using?

Commit 30436a8a9c0f02c58631fa9f775f5a4f0d748466 aiken v1.0.26-alpha+075668b

What operating system are you using, and which version?

Describe what the problem is?

Build is failing with an unknown type for the examples.

aiken/examples/gift_card$ aiken check
    Compiling aiken-lang/gift_card 0.0.0 (/home/ross-spencer/git/aiken/test/aiken/examples/gift_card)
    Resolving aiken-lang/gift_card
      Fetched 1 package in 0.05s from cache
    Compiling aiken-lang/stdlib main (/home/ross-
aiken/examples/gift_card/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.

    ╭─[/home/ross-spencer/git/aiken/test/aiken/examples/gift_card/build/packages/aiken-lang-stdlib/lib/aiken/dict.ak:22:1]
 22 │ pub opaque type Dict<key, value> {
 23 │   inner: AList<ByteArray, value>,
    ·          ───────────┬───────────
    ·                     ╰── unknown type
 24 │ }
    ╰────
  help: Did you mean 'List'?

      Summary 1 error, 0 warnings

What should be the expected behavior?

The examples should pass if there is an update to the codebase or the possible (?) typo corrected in the codebase.

KtorZ commented 2 months ago

Hello, thanks for reporting.

However, I'll just close this issue since the problem comes from an incompatibility between the compiler version you're using and the current version of the standard library.

Since Aiken is still in alpha, we allow sometimes to ship small breaking changes. But we try to limit incompatibility between equivalent version as much as possible. As a rule thumb, you can reasonable assume that:

The gift_card example is configured to use stdlib's main, so you're also expected to use the compiler's main here. Or await for the next release.

ross-spencer commented 2 months ago

Are there any docs changes that should be in the tutorials?

E.g, https://aiken-lang.org/installation-instructions

Rn I'm personally not sure how to access the information you mean, or downgrade to the previous version I was using where this worked. But if I just follow the instructions I get to the place I am in (incompatible compiler with existing examples?)

KtorZ commented 2 months ago

You can force the stdlib's version to be "1.8.0" instead of main in the gift card toml file: https://github.com/aiken-lang/aiken/blob/30436a8a9c0f02c58631fa9f775f5a4f0d748466/examples/gift_card/aiken.toml#L13

This should solve your issue 👍.

Although I am curious; what part of the tutorial did led you to use the main version of the standard library? It could be that aiken new does that by default, which is something we might want to change.