1e7db22e16093406181580039de9304f74c30a03 — Stephen Paul Weber a month ago 8625f08
Integrity check must happen after all resolves
2 files changed, 10 insertions(+), 6 deletions(-)

M lib/dhall/ast.rb
M lib/dhall/resolve.rb
M lib/dhall/ast.rb => lib/dhall/ast.rb +7 -4
@@ 1299,7 1299,8 @@ expr = expr.normalize
  				return expr if expr.cache_key == to_s
  
- 				raise FailureException, "#{expr} does not match #{self}"
+ 				raise FailureException, "#{expr} hash #{expr.cache_key}" \
+ 				                        " does not match #{self}"
  			end
  
  			def as_json


@@ 1317,7 1318,7 @@ def hexdigest; end
  
  			def check(expr)
- 				expr
+ 				expr.normalize
  			end
  
  			def as_json


@@ 1690,8 1691,10 @@ path.chain_onto(relative_to).canonical
  		end
  
- 		def parse_and_check(raw, deadline: Util::NoDeadline.new)
- 			integrity_check.check(import_type.call(raw, deadline: deadline))
+ 		def parse_resolve_check(raw, deadline: Util::NoDeadline.new, **kwargs)
+ 			import_type.call(raw, deadline: deadline).resolve(**kwargs).then do |e|
+ 				integrity_check.check(TypeChecker.annotate(e))
+ 			end
  		end
  
  		def cache_key(relative_to)

M lib/dhall/resolve.rb => lib/dhall/resolve.rb +3 -2
@@ 442,7 442,6 @@ Promise.resolve(nil).then do
  					resolver.cache_fetch(@expr.cache_key(relative_to)) do
  						resolve_raw(resolver: resolver, relative_to: relative_to)
- 							.then(&TypeChecker.method(:annotate)).then(&:normalize)
  					end
  				end
  			end


@@ 450,7 449,9 @@ def resolve_raw(resolver:, relative_to:)
  				real_path = @expr.real_path(relative_to)
  				real_path.resolve(resolver).then do |result|
- 					@expr.parse_and_check(result, deadline: resolver.deadline).resolve(
+ 					@expr.parse_resolve_check(
+ 						result,
+ 						deadline:    resolver.deadline,
  						resolver:    resolver.child(real_path),
  						relative_to: real_path
  					)