hughperman / pure-lang

Automatically exported from code.google.com/p/pure-lang
0 stars 0 forks source link

failed_match exception should include info about the pattern #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
> f x = case x of 0 = 1; end;
> f 2;
<stdin>, line 2: unhandled exception 'failed_match' while evaluating 'f 2'

It would be helpful if the exception somehow indicated which set of
patterns could not be matched. I'm not sure what info you have available at
runtime to append to the exception. For instance, could you include the
line number of the failed 'case' statement or 'with' clause? 

Original issue reported on code.google.com by sedill...@gmail.com on 11 Jan 2009 at 5:46

GoogleCodeExporter commented 8 years ago
I agree that it would be useful to have better runtime diagnostics for 
failed_cond
and failed_match exceptions, but it's difficult to implement this in an 
efficient way
and in any case it would require a major overhaul of the compiler.

None of the relevant information is currently available at runtime. In fact, it 
is
not even available to the compiler, as the actual code generation may take 
place long
after the source has been parsed, and source locations aren't currently 
recorded in
the compiler's internal data structures. Also, the "source" may actually be a 
string
evaluated at runtime, so meaningful source locations can't always be given.

The information that *is* available during compilation is the stack of lexical
environments leading up to the construct (case, when, lambda, if-then-else) 
which
might cause one of these exceptions. But these don't always give meaningful
information either, as most or all of the closures might be anonymous.

I'm leaving this issue open. But I don't consider this a bug, so I set the type 
to
Enhancement instead. Suggestions and, preferably, patches are welcome. :)

Original comment by aggraef@gmail.com on 11 Jan 2009 at 9:24

GoogleCodeExporter commented 8 years ago

Original comment by aggraef@gmail.com on 11 Jan 2009 at 9:26

GoogleCodeExporter commented 8 years ago
I'm closing this issue report now, as no patches were submitted and I don't 
have the
time to work on this either.

Original comment by aggraef@gmail.com on 1 Sep 2009 at 6:15