IntersectMBO / plutus

The Plutus language implementation and tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add term mangling

effectfully opened this issue · comments

We have name mangling tests, we should add similar ones except for mangling arbitrary parts of terms, so that we can declaratively specify what kind of transformations turn a well-typed term into an ill-typed one. The simplest example would be substituting a variable with a term of a different type -- that should never type check in TPLC or PIR.

This is important, because we don't really have any good tests for type checking errors, since PIR generators only produce well-typed terms and we don't have many unit/golden tests either. And we just recently had a nasty bug related to a type checking failure.

This will probably require some interesting tech to pick an arbitrary part of a term, tree-like structures aren't particularly well-suited for that, but I guess we can just enumerate the nodes and pick an arbitrary number within the resulting range.

We'll also need to figure out whether arbitrarily changing a type to a different but still well-kinded one is supposed to always give a type error. I suppose there generally will be plenty of corner cases to consider.