Closed duvenaud closed 1 year ago
So I traced this a little further, and it's due to a current limitation on catch
, that it can't deal with a block that has a functional value. For example:
catch do f64_to_f
> Compiler bug!
> Please report this at github.com/google-research/dex-lang/issues
>
> Pattern match failure in do expression at src/lib/Simplify.hs:891:5-39
> CallStack (from HasCallStack):
> error, called at src/lib/Err.hs:222:12 in dex-0.1.0.0-Gi9B8TxRbicLQnuTnmjlXJ:Err
@dougalm Is that intentional? Should we improve the error message (and put a Data
constraint on catch
once we have that), or should we fix it? Internally, the issue is assuming the block being caught from simplifies with an identity reconstruction.
It occurs in your program @duvenaud because you wrote (unintentionally?) a parser that produces a parser (which internally contains a function). To wit,
:t split_parser
> (Parser (Parser Int32))
which seems like not what you want? Trying to invoke this puts it through the catch
inside run_parser
, producing the crash.
Yes, I don't think I want that behavior, and once I got my parser to work, I didn't have this error anymore. So it's not a blocking issue, I just reported as I went along in case it uncovered something more important.
I'm trying to write a tokenizer in Dex. I could use the parser combinator library to write a simple word-splitter that runs fine at the top level, but when I wrapped it into a function, I got a compiler bug. Here is a MWE:
gives
I realize the above code doesn't do anything useful, it's been stripped down to make a MWE.