Skip to content

[ICE] Empty data type causes EmitCore crash #289

@Y-Nak

Description

@Y-Nak

Summary

Defining an empty data type (a type with no constructors, analogous to Haskell's Void) and using it as an arg/return type causes an ICE in EmitCore.hs. The compiler crashes with "empty sum" error when trying to translate the type.

Minimal Reproduction

data Void;

function todo() -> Void {
    assembly {
        revert(0, 0)
    }
}

contract C {
    function main()  {
        todo();
    }
}

ERROR: empty sum Void
in: function signature function todo () -> Void
in: function todo

sol-core: Emit core failed
CallStack (from HasCallStack):
  error, called at src/Solcore/Desugarer/EmitCore.hs:38:3 in sol-core-0.0.0.0-inplace:Solcore.Desugarer.EmitCore
  errorsEM, called at src/Solcore/Desugarer/EmitCore.hs:214:25 in sol-core-0.0.0.0-inplace:Solcore.Desugarer.EmitCore

TODO: We also probably need to discuss the typing rule for the empty(or bottom) type.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions