Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main thread panicked (some errors) #310

Closed
4 tasks done
Tracked by #191
alessandrokonrad opened this issue Jan 25, 2023 · 5 comments
Closed
4 tasks done
Tracked by #191

Main thread panicked (some errors) #310

alessandrokonrad opened this issue Jan 25, 2023 · 5 comments
Labels
code gen Untyped Plutus Core code generation typechecking Types and inference
Milestone

Comments

@alessandrokonrad
Copy link
Contributor

alessandrokonrad commented Jan 25, 2023

What Git revision are you using?

3c97f05

test sort_by_1() {
  let xs = [[4, 3, 2, 1], [2, 3, 4, 5]]
  when xs is {
    [[x, xs2], [y, ys2]] -> True
  }
}

Command: aiken check
Error:

Error: 
  × Main thread panicked.
  ├─▶ at crates/aiken-lang/src/uplc.rs:1325:52
  ╰─▶ called `Option::unwrap()` on a `None` value
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
use aiken/transaction.{InlineDatum}

test some_test() {
  InlineDatum(Void) == InlineDatum(Void)
}

Command: aiken check
Error:

Error: 
  × Main thread panicked.
  ├─▶ at crates/aiken-lang/src/uplc.rs:4037:66
  ╰─▶ called `Result::unwrap()` on an `Err` value: TypeMismatch(List(Unit), List(Data))
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
type SampleData {
  a: Int,
}

const sample_data = SampleData { a: 1 }

test some_test() {
  sample_data == sample_data
}

Command: aiken check
Error:

Error: 
  × Main thread panicked.
  ├─▶ at crates/aiken-lang/src/builder.rs:730:13
  ╰─▶ not yet implemented
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
use aiken/dict
use aiken/interval.{Interval, IntervalBound, PositiveInfinity}
use aiken/transaction.{
  InlineDatum, Input, Output, OutputReference, Transaction, TransactionId,
}
use aiken/transaction/credential.{
  Address, PublicKeyCredential, ScriptCredential, StakeCredential,
}
use aiken/transaction/value

const keyhash = #[1, 2, 3, 4, 5, 6]

const scripthash = #[6, 5, 4, 3, 2, 1]

pub fn keyhash_address(with_stake_credential: Option<StakeCredential>) {
  Address {
    payment_credential: PublicKeyCredential(keyhash),
    stake_credential: with_stake_credential,
  }
}

pub fn scripthash_address(with_stake_credential: Option<StakeCredential>) {
  Address {
    payment_credential: ScriptCredential(scripthash),
    stake_credential: with_stake_credential,
  }
}

type SampleData {
  a: Int,
  b: ByteArray,
}

pub fn tx_1() -> Transaction {
  let sample_datum = SampleData { a: 1, b: #[1] }
  // let sample_data: Data = sample_datum
  let tx =
    Transaction {
      inputs: [
        Input {
          output_reference: OutputReference {
            transaction_id: TransactionId { hash: #[] },
            output_index: 0,
          },
          output: Output {
            address: scripthash_address(None),
            value: value.zero(),
            datum: InlineDatum(sample_datum),
            reference_script: None,
          },
        },
      ],
      reference_inputs: [],
      outputs: [
        Output {
          address: keyhash_address(None),
          value: value.from_lovelace(10000),
          datum: InlineDatum(sample_datum),
          reference_script: None,
        },
      ],
      fee: value.zero(),
      mint: value.from_asset(#[0, 0, 0], #[0], -1),
      certificates: [],
      withdrawals: dict.new(),
      validity_range: Interval {
        lower_bound: IntervalBound {
          bound_type: PositiveInfinity,
          is_inclusive: True,
        },
        upper_bound: IntervalBound {
          bound_type: PositiveInfinity,
          is_inclusive: True,
        },
      },
      extra_signatories: [keyhash],
      redeemers: dict.new(),
      datums: dict.new(),
      id: TransactionId { hash: #[] },
    }
  tx
}

test some_test() {
  tx_1() == tx_1()
}

Command: aiken check

Error: 
  × Main thread panicked.
  ├─▶ at /Users/ales/.cargo/git/checkouts/aiken-86238d01b727e6a8/3c97f05/crates/aiken-project/src/lib.rs:672:22
  ╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "wormhole/file_tx_1", unique: Unique(7) })
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

I was able to narrow this one down. It seems like it has to do with the no arg function tx_1(). If I add a random argument to it like tx_1(1) then there is no error.

@rvcas
Copy link
Member

rvcas commented Jan 25, 2023

ah ok, yea no arg functions are compile time evaluated, could be some issue there.

@KtorZ KtorZ added typechecking Types and inference code gen Untyped Plutus Core code generation labels Jan 26, 2023
@KtorZ KtorZ modified the milestones: Language PoC, Standard Library Jan 26, 2023
@KtorZ KtorZ mentioned this issue Jan 26, 2023
27 tasks
@rvcas
Copy link
Member

rvcas commented Feb 2, 2023

@alessandrokonrad is this still an issue?

@alessandrokonrad
Copy link
Contributor Author

@rvcas Error 2,3 and 4 still throw Main thread panicked. I'm on this rev now 4c8221e

KtorZ added a commit that referenced this issue Feb 13, 2023
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:1451:52
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```

  See also: #310
MicroProofs pushed a commit that referenced this issue Feb 15, 2023
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:1451:52
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```

  See also: #310
MicroProofs pushed a commit that referenced this issue Feb 15, 2023
  ```
  Error:
    × Main thread panicked.
    ├─▶ at crates/aiken-lang/src/uplc.rs:1451:52
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```

  See also: #310
@MicroProofs
Copy link
Member

I think these are all passing or banned by type checker. Can you verify @alessandrokonrad?

@alessandrokonrad
Copy link
Contributor Author

@MicroProofs it's all working great now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code gen Untyped Plutus Core code generation typechecking Types and inference
Projects
Status: 🚀 Released
Development

No branches or pull requests

4 participants