-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates and minor bug fix to precedence parsing of function clauses
Consider the following program: infix & && << >> datatype ('a, 'b) p = & of 'a * 'b (* should error *) fun (_ f _) = () (* should error *) fun fst x & y = x (* should error *) fun fst x && y = x (* should error *) fun << (x, y) = () (* should error *) fun << (x, y) z = () (* should error *) fun << && >> = () (* should error *) fun (f) x = () (* should error *) fun x && y & z = 1 Each of these function declarations erroneously uses infix identifiers in a function clause. Previously, only the second, seventh, and eighth were reported as errors: Error: z.sml 8.11-8.11. Constructor used without argument in pattern: &. Error: z.sml 23.6-23.6. Function defined with illegal name: f. in: fun f x = () Error: z.sml 26.12-26.12. Constructor used without argument in pattern: &. Now, we give more descriptive error messages: Error: z.sml 5.5-5.11. Function clause with improper infix pattern. in: fun (_ f _) = () Error: z.sml 5.5-5.11. Function clause with no arguments. in: fun (_ f _) = () Error: z.sml 8.5-8.9. Function clause with improper infix pattern. in: fun fst x & y = x Warning: z.sml 8.11-8.11. Constructor redefined by fun: &. in: fun fst x & y = x Error: z.sml 8.5-8.7. Undefined constructor: fst. Error: z.sml 8.17-8.17. Undefined variable: x. Error: z.sml 11.5-11.9. Function clause with improper infix pattern. in: fun fst x && y = x Error: z.sml 11.5-11.7. Undefined constructor: fst. Error: z.sml 11.18-11.18. Undefined variable: x. Error: z.sml 14.5-14.6. Function clause starts with infix identifier: <<. in: fun << (x, y) = () Error: z.sml 17.5-17.6. Function clause starts with infix identifier: <<. in: fun << (x, y) z = () Error: z.sml 20.5-20.6. Function clause starts with infix identifier: <<. in: fun << && >> = () Error: z.sml 20.11-20.12. Identifier must be used infix: >>. in: fun << && >> = () Error: z.sml 23.5-23.7. Function clause with improper infix pattern. in: fun f x = () Error: z.sml 26.5-26.10. Function clause with improper infix pattern. in: fun x && y & z = 1 Error: z.sml 26.7-26.8. Undefined constructor: &&.
- Loading branch information
1 parent
37ddbe5
commit 1a6d25e
Showing
3 changed files
with
599 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.