From 7fe9c669d256bafcd6fdf31df1a1fc14004db4e1 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 28 Apr 2015 16:19:19 -0400 Subject: [PATCH] Better linting of ifs --- harlan/front/lint.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/harlan/front/lint.scm b/harlan/front/lint.scm index 11e641e..c86a217 100644 --- a/harlan/front/lint.scm +++ b/harlan/front/lint.scm @@ -47,10 +47,17 @@ dups))))) (define (check-if expr env context) - (if (eq? context 'expr) - (match expr - ((if ,t ,c) - (err expr "One-armed if found in expression context. Try adding a case for if the test is false."))))) + (match expr + ((if ,t ,c) + (if (eq? context 'expr) + (err expr "One-armed if found in expression context. Try adding a case for if the test is false.") + (begin (check-expr t env) + (check-expr c env)))) + ((if ,t ,c ,a) + (check-expr t env) + (check-expr c env) + (check-expr a env)) + (,else (err expr "Incorrect number of arguments for if. If should consist of a test, a then expression/statement and also an else expression/statement.")))) (define (check-error expr env context) (match expr