GaloisInc / daedalus

The Daedalus data description language
BSD 3-Clause "New" or "Revised" License
63 stars 11 forks source link

Crash using as? in a boolean expression in a pure function #357

Open sauclovian-g opened 9 months ago

sauclovian-g commented 9 months ago

Running daedalus show-types on the attached bug1.ddl crashes like this:

%< --------------------------------------------------- 
  Revision:  UNKNOWN
  Branch:    UNKNOWN
  Location:  inferIf
  Message:   Lifted in non-grammar context
CallStack (from HasCallStack):
  panic, called at src/Daedalus/Panic.hs:17:9 in ddls-tls-0.1.0.0-4dcae23e:Daedalus.Panic
  panic, called at src/Daedalus/Type.hs:1140:28 in ddls-0.1.0.0-b71bc38c:Daedalus.Type
%< --------------------------------------------------- 

It uses an as? to cast 0 to a bitdata type; both no cast and an unconditional cast are rejected (I think wrongly, 0 is supposed to be a valid value of the type and nothing in the definition ought to be ruling it out) ... so I tried the dynamic cast and it crashed :-(

The attached file is a cut-down fragment from part of an ELF spec.

bug1.ddl.txt (it won't let me attach .ddl files without renaming them. wut?)