Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#123] missing warning for non-exaustive binding at top level

Date:
2014-01-03 02:08
Priority:
3
State:
Closed
Submitted by:
Bug Submitter (webuser)
Assigned to:
David MacQueen (dbm)
Machine Architecture:
None
Operating System:
Generic Unix
Component:
Compiler
Resolution:
None
Severity:
Minor
OS Version:
SML/NJ Version:
110.76
Keywords:
binding top-level
URL:
Transcript (of reproduction):
% sml Standard ML of New Jersey v110.76 [built: Mon Aug 19 10:38:12 2013] - datatype ty = A | B of int; datatype ty = A | B of int - fun f x = let val B j = x in j end; val f = fn : ty - int - f A; uncaught exception Bind [nonexhaustive binding failure] raised at: stdIn:7.19-7.26
Source (for reproduction):
datatype ty = A | B of int; fun f x = let val B j = x in j end;
Summary:
missing warning for non-exaustive binding at top level

Detailed description
No warning is generated for a non-exhaustive binding in a top-level function
Additional comments:
This issue came up on the MLton mailing list.

Submitted via web form by John Reppy jhr@cs.uchicago.edu

Comments:

Message  ↓
Date: 2017-09-18 19:33
Sender: David MacQueen

The fix is to remove the call of ElabUtil.completeMatch in mkVBs, which was redundantly adding a default rule on top of the manually added default rule (eliminating the manually added rule and using completeMatch to add it did not work because of some problem with the type type information associated with the rule).

Date: 2017-09-18 17:37
Sender: David MacQueen

The problem is that the way that let expressions (and particularly their declaration part) is translated in FLINT/trans/translate.sml (see mkVBs) directly builds an exhaustive CASE expression rather than calling matchcomp, which is where the nonexhaustive match warning is generated. So nonexhaustive warnings will never be generated for let bindings, top-level or not. One possible fix would be to create the simple one-branch case for the let and apply the matchcomp function to that to check for nonexhaustive let bindings.

Attached Files:

Changes

Field Old Value Date By
status_idOpen2017-09-18 19:33dbm
close_dateNone2017-09-18 19:33dbm
detailsNo warning is generated for a non-exhaustive binding in a top-level function Additional comments: This issue came up on the MLton mailing list. Submitted via web form by John Reppy jhr@cs.uchicago.edu 2017-09-18 17:37dbm
assigned_tonone2014-01-03 02:38jhr