IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.57k stars 476 forks source link

plc evaluate fails on example program #3462

Closed arthurgreef closed 3 years ago

arthurgreef commented 3 years ago

Area

[X] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code [] Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries [] Marlowe Related to Marlowe [] Other Any other topic (Playgrounds, etc.)

Summary

Execute the following program taking from the plutus-core readme.md file.

echo "(program 0.1.0 [ (lam x0 (con bool) [ [ (builtin dropByteString) [ [ (builtin multiplyInteger) [ [ (builtin addInteger) (con integer 3) ] (con integer 3) ] ] [ [ (builtin multiplyInteger) (con integer 2) ] (con integer 1) ] ] ] [ (builtin sha3_256) [ [ (builtin takeByteString) (con integer 2) ] (con bytestring #7661) ] ] ] ) [ [ (builtin greaterThanInteger) [ [ (builtin multiplyInteger) [ [ (builtin multiplyInteger) (con integer 2) ] (con integer 0) ] ] [ [ (builtin subtractInteger) (con integer 3) ] (con integer 3) ] ] ] [ [ (builtin addInteger) [ [ (builtin multiplyInteger) (con integer 1) ] (con integer 1) ] ] [ [ (builtin addInteger) (con integer 1) ] (con integer 1) ] ] ] ] )" | ./result/bin/plc evaluate --stdin

Expected Ouptut: A correct evaluation of the program

Actual Output: plc: Unexpected ')' at line 1, column 35

A clear and specific description of what the bug is.

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

System info (please complete the following information):

Screenshots and attachments

Additional context

Add any other context about the problem here.

effectfully commented 3 years ago

@thealmarty I've assigned it to you, but I'm not actually sure if it's a problem with the parser or just an outdated example.

thealmarty commented 3 years ago

It can't be the new parser yet because it's technically not deployed (it currently co-exists with the current one).

I noticed that it's a typed program, so you'd need to add --typed to specify that. But there is no CEK machine for Typed Plutus Core for plc, so we need to specify the mode to be CK. If you save that program in eg.plc, you should get this:

cabal run plc evaluate -- -m CK --typed -i eg.plc 
Up to date
(con bytestring #4b6e4ba90e78b6601bc63c806d34f914b983acc3)