-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f328468
commit 6e483e7
Showing
5 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
module Test { | ||
fun test : Bool { | ||
!!!!!"fun" && !!!![1] && !1 | ||
!!!!!true && !!!!false && !false | ||
} | ||
} | ||
-------------------------------------------------------------------------------- | ||
module Test { | ||
fun test : Bool { | ||
!"fun" && !![1] && !1 | ||
!true && !!false && !false | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Test { | ||
fun test : Bool { | ||
!false | ||
} | ||
} | ||
--------------------------------------------------------NegatedExpressionNotBool | ||
module Test { | ||
fun test : Bool { | ||
!"asd" | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
message NegatedExpressionNotBool do | ||
title "Type Error" | ||
|
||
block do | ||
text "A negated expressions expression must evaluate to bool." | ||
end | ||
|
||
was_expecting_type expected, got | ||
|
||
snippet node | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
module Mint | ||
class TypeChecker | ||
type_error NegatedExpressionNotBool | ||
|
||
def check(node : Ast::NegatedExpression) : Type | ||
BOOL | ||
expression = | ||
check node.expression | ||
|
||
raise NegatedExpressionNotBool, { | ||
"got" => expression, | ||
"expected" => BOOL, | ||
} unless Comparer.compare(BOOL, expression) | ||
|
||
expression | ||
end | ||
end | ||
end |