plutus
plutus copied to clipboard
Add a way to generate callstack trace message
closes #7146. ~~Add plugin option to generate callstack trace message. Currently this won't handle cases when a function has PlutusTx.Trace.callStack and that function is called in multiple places. It will just use callstack of the first occurance :/ (working on it. more detail on first commit message).~~
I redid everything, now it will have correct callstack, but with some execution cost overhead. I'm not too unhappy about this since callstack in general is almost exclusively used for debug scripts anyways.
Example
-- SillyCalss.hs
class SillyClass a where
sillyThing :: a -> Integer
instance SillyClass Integer where
sillyThing = traceError callStack
-- Demo.hs
rob :: Integer -> Integer -> Integer
rob x = sillyThing @Integer
-- entrypoint
tom :: Integer -> Integer
tom = rob (x PTx.+ 20)
tom:demo/Demo.hs:44:1-44:3
\-rob:demo/Demo.hs:32:1-32:3
\-$fSillyClassInteger
\-$fSillyClassInteger_$csillyThing