M lib/dhall/typecheck.rb => lib/dhall/typecheck.rb +5 -9
@@ 620,9 620,9 @@ module Dhall
annotated_value = @value.annotate(context)
type = Dhall::UnionType.new(
- alternatives: Hash[@union.alternatives.alternatives.merge(
- @union.tag => annotated_value.type
- ).sort]
+ alternatives: { @union.tag => annotated_value.type }.merge(
+ @union.alternatives.alternatives
+ )
)
# Annotate to sanity check
@@ 800,13 800,9 @@ module Dhall
"#{@let.type}, #{aassign.type}"
end
- Dhall::Function.disable_alpha_normalization!
- nassign = @let.assign.normalize.shift(1, @let.var, 0)
- Dhall::Function.enable_alpha_normalization!
-
abody = TypeChecker.for(@letblock.body.substitute(
Dhall::Variable[@let.var],
- nassign
+ @let.assign.shift(1, @let.var, 0)
).shift(-1, @let.var, 0)).annotate(context)
ablock = @letblock.with(
@@ 832,7 828,7 @@ module Dhall
def annotate(context)
redo_annotation = TypeChecker.for(@expr.value).annotate(context)
- if redo_annotation.type == @expr.type
+ if redo_annotation.type.normalize == @expr.type.normalize
redo_annotation
else
raise TypeError, "TypeAnnotation does not match: " \
M test/test_typechecker.rb => test/test_typechecker.rb +7 -4
@@ 15,11 15,14 @@ class TestTypechecker < Minitest::Test
next if test =~ /prelude/
define_method("test_#{test}") do
- assert_equal(
- Dhall.from_binary((TESTS + "#{test}B.dhallb").binread),
+ assert_kind_of(
+ Dhall::TypeAnnotation,
Dhall::TypeChecker.for(
- Dhall.from_binary(path.binread)
- ).annotate(Dhall::TypeChecker::Context.new).type
+ Dhall::TypeAnnotation.new(
+ value: Dhall.from_binary(path.binread),
+ type: Dhall.from_binary((TESTS + "#{test}B.dhallb").binread)
+ )
+ ).annotate(Dhall::TypeChecker::Context.new)
)
end
end