Skip to content

Commit

Permalink
Better linting of ifs
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed Apr 28, 2015
1 parent 30e3089 commit 7fe9c66
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions harlan/front/lint.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7fe9c66

Please sign in to comment.