essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 4 forks source link

Compiler internal error during flattening in simple contract with enum: `custom type present in final intent expr_types slotmap` #648

Closed mitchmindtree closed 1 month ago

mitchmindtree commented 5 months ago

While working on #630, I ran into an error in my simple test contract and noticed that it still occurred without any dependencies.

Here's the pint contract I'm compiling using master version of pintc:

enum Animal = Cat | Dog;

type Person = {
    age: int,
    pet: Animal,
};

var bob = {
    age: 42,
    pet: Animal::Cat,
};

constraint bob.pet != Animal::Dog;
solve satisfy;

And here's the error:

$ pintc contract.pnt
Error: compiler internal error: custom type present in final intent expr_types slotmap
   ╭─[contract.pnt:1:1]
   │
 1 │ enum Animal = Cat | Dog;
   │ ───────────┬───────────
   │            ╰───────────── custom type present in final intent expr_types slotmap
───╯
Error: compiler internal error: custom type present in final intent expr_types slotmap
   ╭─[contract.pnt:1:1]
   │
 1 │ enum Animal = Cat | Dog;
   │ ───────────┬───────────
   │            ╰───────────── custom type present in final intent expr_types slotmap
───╯
Error: could not compile `contract.pnt` due to 2 previous errors
mohammadfawaz commented 2 months ago

Updated syntax that exposes this:

enum Animal = Cat | Dog;

type Person = {
    age: int,
    pet: Animal,
};

predicate Foo {
    var bob = {
        age: 42,
        pet: Animal::Cat,
    };

    constraint bob.pet != Animal::Dog;
}