Skip to content

Commit

Permalink
Add minimal example for reproducing PIR simplifier bug
Browse files Browse the repository at this point in the history
  • Loading branch information
koslambrou committed Jun 6, 2024
1 parent 88ad493 commit 1e2dec1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
45 changes: 45 additions & 0 deletions plutus-tx-plugin/app/SimplifierBugMinimalExample.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- editorconfig-checker-disable-file
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

-- Comment out in order to reproduce the compilation issue.
-- WATCH OUT: THIS IS PROBABLY GOING TO OOO YOUR MACHINE
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-simplifier-iterations-pir=1 #-}

module Main where

import PlutusTx qualified
import PlutusTx.Prelude hiding (Semigroup (..), unless)
import Prelude qualified as H

main :: H.IO ()
main = do
H.pure ()

data C = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R

PlutusTx.makeIsDataIndexed ''C [ ('A, 0) , ('B, 1) , ('C, 2) , ('D, 3) , ('E, 4) , ('F, 5) , ('G, 6) , ('H, 7) , ('I, 8) , ('J, 9) , ('K, 10) , ('L, 11) , ('M, 12) , ('N, 13) , ('O, 14) , ('P, 15) , ('Q, 16) , ('R, 17) ]

{-# INLINABLE validator #-}
validator ::
BuiltinData
-> BuiltinData
-> BuiltinData
-> Bool
validator d _ _ =
let !_ = PlutusTx.unsafeFromBuiltinData @C d
in True

unappliedValidator ::
PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> BuiltinUnit)
unappliedValidator =
$$(PlutusTx.compile [|| \d r c -> check $ validator d r c ||])

12 changes: 12 additions & 0 deletions plutus-tx-plugin/plutus-tx-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ executable gen-plugin-opts-doc

default-language: Haskell2010

executable simplifier-bug-minimal-example
import: lang, ghc-version-support
main-is: SimplifierBugMinimalExample.hs
hs-source-dirs: app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
, base >=4.7 && <5
, plutus-tx
, plutus-tx-plugin ^>=1.29

default-language: Haskell2010

test-suite plutus-tx-plugin-tests
import: lang, ghc-version-support

Expand Down

0 comments on commit 1e2dec1

Please sign in to comment.