aiken-lang / aiken

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

using side effects #967

Closed waalge closed 1 week ago

waalge commented 1 month ago
fn get_thing_with_checks() {
  // do some expects and return something
}

With

   // when i want checks done but don't need the return 
  expect _thing = get_thing_with_checks()

Aiken says

  help: If your type has one constructor, unless you are casting from Data, you can
  prefer using a let binding like so...

With

   let _thing = get_thing_with_checks()

Aiken says:

  help: If you do want to enforce some side-effects, use expect with _total instead of let.
MicroProofs commented 2 weeks ago

Try let Void = ...

waalge commented 1 week ago
 60 │         let Void = get_thing_with_checks()
    ·             ──┬─
    ·               ╰── expected type 'Int'
rvcas commented 1 week ago

Why does get_thing_with_checks return an Int?

waalge commented 1 week ago

I guess my description was too terse. I have a function that is used in multiple places. Some places I return the value to do additional logic. Other places I need to know only that the conditions of the value existing are as expected.

thing here is of type int.