From: GitHub <no...@gi...> - 2015-10-06 17:02:50
|
Branch: refs/heads/master Home: https://github.com/MLton/mlton Commit: 8e9acfa283669ce644a9de06df36d91f6a113d30 https://github.com/MLton/mlton/commit/8e9acfa283669ce644a9de06df36d91f6a113d30 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-16 (Sun, 16 Aug 2015) Changed paths: M mlton/match-compile/nested-pat.fun Log Message: ----------- Trace 'NestedPat.flatten' Commit: 9c919cd86dd849f250c48c885735cce2549bceb0 https://github.com/MLton/mlton/commit/9c919cd86dd849f250c48c885735cce2549bceb0 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-16 (Sun, 16 Aug 2015) Changed paths: M mlton/defunctorize/defunctorize.fun Log Message: ----------- Fix non-exhaustive match warnings with or-patterns. Fixes MLton/mlton#115. Commit: 98d33ad89a966a6596b5337d8c9bf06c20994804 https://github.com/MLton/mlton/commit/98d33ad89a966a6596b5337d8c9bf06c20994804 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/match-compile/nested-pat.fun Log Message: ----------- Pretty print NestedPat.Or with | separators Commit: 5287151ac4f5955f28b91f10d02cb6c259bd8634 https://github.com/MLton/mlton/commit/5287151ac4f5955f28b91f10d02cb6c259bd8634 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/match-compile/nested-pat.fun Log Message: ----------- Make code style improvements to NestedPat.flatten Commit: c55a1fbe3174e3c4a13ac94aebaed2b7e60fa3cd https://github.com/MLton/mlton/commit/c55a1fbe3174e3c4a13ac94aebaed2b7e60fa3cd Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/match-compile/nested-pat.fun Log Message: ----------- Fix NestedPat.varsAndTypes on or-patterns It is only necessary to return the vars and types of the first pattern in an or-pattern. All other patterns must have the same set of vars and types. Commit: 7aa24d96071945b2543f5f32b59d1ea9b040153a https://github.com/MLton/mlton/commit/7aa24d96071945b2543f5f32b59d1ea9b040153a Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/defunctorize/defunctorize.fun Log Message: ----------- Update comment regarding expansion of poly pats in val decs Commit: ccc72e447244a40f70d202c4d53b1b43c008b773 https://github.com/MLton/mlton/commit/ccc72e447244a40f70d202c4d53b1b43c008b773 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/defunctorize/defunctorize.fun Log Message: ----------- Simplify logic for CoreML to XML conversion of val decs Commit: aeb4ac0976470fcc2d1258d32891a8600d9b09d1 https://github.com/MLton/mlton/commit/aeb4ac0976470fcc2d1258d32891a8600d9b09d1 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-19 (Wed, 19 Aug 2015) Changed paths: M mlton/defunctorize/defunctorize.fun M mlton/match-compile/match-compile.fun M mlton/match-compile/match-compile.sig Log Message: ----------- Report redundancy in matches with or-patterns Determine if a match rule has redundancy by comparing the number of flattened patterns to the number of uses of the rhs expression. Commit: 85aa139cc661a09fdd877b68d63c7ca517776e57 https://github.com/MLton/mlton/commit/85aa139cc661a09fdd877b68d63c7ca517776e57 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-20 (Thu, 20 Aug 2015) Changed paths: M mlton/defunctorize/defunctorize.fun Log Message: ----------- Distinguish between fully and partially redundant patterns Consider the following example: datatype a = A1 | A2 | A3 fun f a = case a of A1 => 1 | (A1 | A2 | A3) => 2 | _ => 3 The second match rule is partially redundant, since the A3 pattern will never match. The third match rule is fully redundant, since the _ pattern will never match. Note that partially redundant matches can only arise with or-patterns. The following error messages are generated: Warning: a.sml 3.5. Case has rules with redundancy. rules: (A1 | A2 | A3) => 2 in: case a of A1 => 1 | (A1 | A2 | A3) => 2 | _ => 3 Warning: a.sml 3.5. Case has redundant rules. rules: _ => 3 in: case a of A1 => 1 | (A1 | A2 | A3) => 2 | _ => 3 Commit: c23d43079d7bb204aeef67b4922799fcf3bfd315 https://github.com/MLton/mlton/commit/c23d43079d7bb204aeef67b4922799fcf3bfd315 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-20 (Thu, 20 Aug 2015) Changed paths: M mlton/ast/ast-core.fun M mlton/front-end/ml.grm Log Message: ----------- Lower precedence of or-patterns in parser Make or-patterns lower precedence than as-patterns and constraint-patterns, much as orelse expressions have lower precedence than andalso-expressions and constraint-expressions. The following is now accepted: fun isVowel c = case c of #"a" | #"e" | #"i" | #"o" | #"u" => true | _ => false whereas, previously, only the following was accepted: fun isVowel c = case c of (#"a" | #"e" | #"i" | #"o" | #"u") => true | _ => false Commit: 6e7a7ca27cc30ecdaf41a8c34b7569b752114384 https://github.com/MLton/mlton/commit/6e7a7ca27cc30ecdaf41a8c34b7569b752114384 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-20 (Thu, 20 Aug 2015) Changed paths: M mlton/ast/ast-core.fun M mlton/ast/ast-core.sig M mlton/elaborate/elaborate-core.fun Log Message: ----------- Pretty print rules in case-expressions and standalone consistently There was a minor inconsistency in the pretty printing of match rules, exemplified by the following warning: Warning: z.sml 11.4. Case has rules with redundancy. rules: A1 | A1 => 1 in: case a of (A1 | A1) => 1 | _ => 2 This warning now prints as: Warning: z.sml 11.4. Case has rules with redundancy. rules: (A1 | A1) => 1 in: case a of (A1 | A1) => 1 Commit: c14dd3fb9edbf3f8468962fa69950edf769a0823 https://github.com/MLton/mlton/commit/c14dd3fb9edbf3f8468962fa69950edf769a0823 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-20 (Thu, 20 Aug 2015) Changed paths: M mlton/ast/ast-core.fun Log Message: ----------- Always pretty print or-patterns with parens Consider the following program: datatype t = T1 | T2 of int fun f1 t = case t of _ => true | T1 => false | T2 _ => false | T1 | T2 _ => false | (T1 | T2 _) | (T1 | T2 _) => false | x as (T1 | T2 _) | x as (T1 | T2 _) => false fun f2 l = case l of _ => true | [T1 | T2 _] => false fun f3 r = case r of _ => true | {t = T1 | T2 _} => false The previous pretty printing of or-patterns would yield the following warning messages: Warning: y.sml 5.4. Case has redundant rules. rules: T1 => false (T2 _) => false (T1 | T2 _) => false (T1 | T2 _ | T1 | T2 _) => false (x as T1 | T2 _ | x as T1 | T2 _) => false in: case t of _ => true | T1 => false ... T1 | T2 _) => false Warning: y.sml 14.4. Case has redundant rules. rules: [T1 | T2 _] => false in: case l of _ => true | [T1 | T2 _] => false Warning: y.sml 19.4. Case has redundant rules. rules: {t = T1 | T2 _} => false in: case r of _ => true | {t = T1 | T2 _} => false Note that the fifth and sixth match rules of f1 are pretty printed with insufficient parens. With the current grammar/ast, it is not trivial to detect the nesting of patterns, as a parenthesized pattern is wrapped in a singleton Ast.Pat.FlatApp. Now the pretty printing of or-patterns yields the following warning messages: Warning: y.sml 5.4. Case has redundant rules. rules: T1 => false (T2 _) => false (T1 | T2 _) => false ((T1 | T2 _) | (T1 | T2 _)) => false (x as (T1 | T2 _) | x as (T1 | T2 _)) => false in: case t of _ => true | T1 => false ... T1 | T2 _)) => false Warning: y.sml 14.4. Case has redundant rules. rules: [(T1 | T2 _)] => false in: case l of _ => true | [(T1 | T2 _)] => false Warning: y.sml 19.4. Case has redundant rules. rules: {t = (T1 | T2 _)} => false in: case r of _ => true | {t = (T1 | T2 _)} => false Note that the fifth and sixth match rules of f1 are pretty printed with sufficient parens, but the second match rules of f2 and f3 are printed with extraneous parens. In general, it is desirable to never pretty print with insufficient parens, even at the expense of occasionally pretty printing with extraneous parens. Commit: 4ff8dad525c050df33bd0d8e13ab4b11c2278159 https://github.com/MLton/mlton/commit/4ff8dad525c050df33bd0d8e13ab4b11c2278159 Author: Matthew Fluet <mat...@gm...> Date: 2015-08-21 (Fri, 21 Aug 2015) Changed paths: M mlton/core-ml/core-ml.fun M mlton/core-ml/core-ml.sig M mlton/defunctorize/defunctorize.fun M mlton/elaborate/elaborate-core.fun M mlton/elaborate/elaborate-env.fun Log Message: ----------- Report partial redundancy in val declarations Consider the following program: datatype a = A1 of int | A2 of int val (A1 x | A1 x) = A1 1 The pattern is partially redundant and non exhaustive. The following error messages are generated: Warning: x.sml 3.5. Declaration is not exhaustive. missing pattern: (A2 _) in: (A1 x | A1 x) = A1 1 Warning: x.sml 3.5. Declaration has rules with redundancy. rules: (A1 x | A1 x) in: (A1 x | A1 x) = A1 1 Commit: 431e42eb444fd5d6bb6f6e3a60b3f43accc7997c https://github.com/MLton/mlton/commit/431e42eb444fd5d6bb6f6e3a60b3f43accc7997c Author: Matthew Fluet <mat...@gm...> Date: 2015-08-23 (Sun, 23 Aug 2015) Changed paths: M mlton/core-ml/core-ml.fun M mlton/core-ml/core-ml.sig M mlton/defunctorize/defunctorize.fun M mlton/elaborate/elaborate-core.fun Log Message: ----------- Make cosmetic improvements to redundant and nonexhaustive diagnostics A number of source-level constructs can give rise to redundant and nonexhaustive diagnostics. Consider the following program: datatype a = A1 of int | A2 of int fun f1 (A1 x | A1 x) = x + 1 val f2 = fn (A1 x | A1 x) => x + 1 val rec f3 = fn (A1 x | A1 x) => x + 1 val (A1 x | A1 x) = A1 1 Previously, the following error messages were generated: Warning: x.sml 4.1. Function is not exhaustive. missing pattern: (A2 _) in: f1 (A1 x | A1 x) = x + 1 Warning: x.sml 4.1. Function has rules with redundancy. rules: f1 (A1 x | A1 x) = x + 1 in: f1 (A1 x | A1 x) = x + 1 Warning: x.sml 6.13. Function is not exhaustive. missing pattern: (A2 _) in: fn (A1 x | A1 x) => (x + 1) Warning: x.sml 6.13. Function has rules with redundancy. rules: (A1 x | A1 x) => (x + 1) in: fn (A1 x | A1 x) => (x + 1) Warning: x.sml 8.17. Function is not exhaustive. missing pattern: (A2 _) in: val rec f3 = fn (A1 x | A1 x) => (x + 1) Warning: x.sml 8.17. Function has rules with redundancy. rules: (A1 x | A1 x) => (x + 1) in: val rec f3 = fn (A1 x | A1 x) => (x + 1) Warning: x.sml 10.5. Declaration is not exhaustive. missing pattern: (A2 _) in: (A1 x | A1 x) = A1 1 Warning: x.sml 10.5. Declaration has rules with redundancy. rules: (A1 x | A1 x) in: (A1 x | A1 x) = A1 1 In particular, note that the last error message refers the the "rules" of a declaration. Also note that when there is both redundancy and nonexhaustiveness, the nonexhaustive error is given earlier. Now, the following error messages are generated: Warning: x.sml 4.1. Function has clauses with redundancy. clauses: f1 (A1 x | A1 x) = x + 1 in: f1 (A1 x | A1 x) = x + 1 Warning: x.sml 4.1. Function is not exhaustive. missing pattern: (A2 _) in: f1 (A1 x | A1 x) = x + 1 Warning: x.sml 6.13. Function has rules with redundancy. rules: (A1 x | A1 x) => (x + 1) in: fn (A1 x | A1 x) => (x + 1) Warning: x.sml 6.13. Function is not exhaustive. missing pattern: (A2 _) in: fn (A1 x | A1 x) => (x + 1) Warning: x.sml 8.17. Function has rules with redundancy. rules: (A1 x | A1 x) => (x + 1) in: val rec f3 = fn (A1 x | A1 x) => (x + 1) Warning: x.sml 8.17. Function is not exhaustive. missing pattern: (A2 _) in: val rec f3 = fn (A1 x | A1 x) => (x + 1) Warning: x.sml 10.5. Declaration has pattern with redundancy. pattern: (A1 x | A1 x) in: (A1 x | A1 x) = A1 1 Warning: x.sml 10.5. Declaration is not exhaustive. missing pattern: (A2 _) in: (A1 x | A1 x) = A1 1 In particular, redundancy errors come before nonexhaustive errors, "fun" functions have redundant "clauses", and "val" declarations have a redundant "pattern". Commit: 0cdc1f1f33724d1065d3a08b00f7fadab6c8f7e4 https://github.com/MLton/mlton/commit/0cdc1f1f33724d1065d3a08b00f7fadab6c8f7e4 Author: Matthew Fluet <mat...@gm...> Date: 2015-09-04 (Fri, 04 Sep 2015) Changed paths: M mlton/ast/ast-core.fun M mlton/match-compile/nested-pat.fun Log Message: ----------- Unify pretty printing of AST.Pat.t and NestedPat.t Commit: bf6153c54ee6e625daebb1992f7d8f125fab0aad https://github.com/MLton/mlton/commit/bf6153c54ee6e625daebb1992f7d8f125fab0aad Author: Matthew Fluet <mat...@gm...> Date: 2015-09-15 (Tue, 15 Sep 2015) Changed paths: M mlton/ast/ast-core.fun M mlton/defunctorize/defunctorize.fun M mlton/match-compile/match-compile.fun M mlton/match-compile/nested-pat.fun Log Message: ----------- Make cosmetic improvements to nonexhaustive diagnostics Consider the following program: datatype a = A1 of int * int | A2 of int | A3 of int | A4 of int * int | A5 of int | A6 of int datatype b = B1 of a | B2 of a * a fun f1 b = case b of B1 (A1 (x,_) | A2 x) => x + 1 | B2 (A3 y, A5 z) => y + z fun f2 b = case b of B1 _ => true fun f3 b = case b of (A3 y, A5 z) => y + z Previously, the following error messages were generated: Warning: w.sml 6.3. Case is not exhaustive. missing pattern: (B2 ((A1 _) | (A2 _) | (A4 _) | (A5 _) | (A6 _), _)) | (B2 ((A3 _), (A1 _) | (A2 _) | (A3 _) | (A4 _) | (A6 _))) | (B1 (A3 _) | (A4 _) | (A5 _) | (A6 _)) in: case b of (B1 (A1 (x, _) |A2 x)) ... y, A5 z)) => (y + z) Warning: w.sml 9.3. Case is not exhaustive. missing pattern: (B2 _) in: case b of (B1 _) => true Warning: w.sml 12.3. Case is not exhaustive. missing pattern: ((A1 _) | (A2 _) | (A4 _) | (A5 _) | (A6 _), _) | ((A3 _), (A1 _) | (A2 _) | (A3 _) | (A4 _) | (A6 _)) in: case b of (A3 y, A5 z) => (y + z) In the first warning, there are insufficient parens for the or-pattern argument to the B1 constructor and extraneous parens around some of the AX constructors. It is also curious that the B2 constructor patterns are given before the B1 constructor patterns. In the second warning, there are extraneous parens around the B1 _ pattern. Now, the following error messages are generated: Warning: w.sml 6.3. Case is not exhaustive. missing pattern: (B1 (A3 _ | A4 _ | A5 _ | A6 _) | B2 (A3 _, (A1 _ | A2 _ | A3 _ | A4 _ | A6 _)) | B2 ((A1 _ | A2 _ | A4 _ | A5 _ | A6 _), _)) in: case b of B1 (A1 (x, _) | A2 x) = ... y, A5 z) => (y + z) Warning: w.sml 9.3. Case is not exhaustive. missing pattern: B2 _ in: case b of B1 _ => true Warning: w.sml 12.3. Case is not exhaustive. missing pattern: ((A3 _, (A1 _ | A2 _ | A3 _ | A4 _ | A6 _)) | ((A1 _ | A2 _ | A4 _ | A5 _ | A6 _), _)) in: case b of (A3 y, A5 z) => (y + z) The missing pattern examples are now pretty-printed in the same manner as other patterns. Commit: f4273fd2b873ca77d0f49986d940c3c663687d1a https://github.com/MLton/mlton/commit/f4273fd2b873ca77d0f49986d940c3c663687d1a Author: Matthew Fluet <Mat...@gm...> Date: 2015-10-06 (Tue, 06 Oct 2015) Changed paths: M mlton/ast/ast-core.fun M mlton/ast/ast-core.sig M mlton/core-ml/core-ml.fun M mlton/core-ml/core-ml.sig M mlton/defunctorize/defunctorize.fun M mlton/elaborate/elaborate-core.fun M mlton/elaborate/elaborate-env.fun M mlton/front-end/ml.grm M mlton/match-compile/match-compile.fun M mlton/match-compile/match-compile.sig M mlton/match-compile/nested-pat.fun Log Message: ----------- Merge pull request #121 from MatthewFluet/or-patterns-updates Provide better diagnostic support for or-patterns Highlights: * Fix non-exhaustive match warnings with or-patterns. Fixes MLton/mlton#115. * Distinguish between partial and fully redundant matches. * Report partial redundancy in val declarations. * Lower precedence of or-patterns in parser. * A variety of cosmetic improvements to non-exhaustive and redundant error/warn messages, primarily to be consistent in formatting between quoted AST and generated messages. Compare: https://github.com/MLton/mlton/compare/c611cbbf9a88...f4273fd2b873 |