M lib/dhall/ast.rb => lib/dhall/ast.rb +4 -0
@@ 613,6 613,10 @@ module Dhall
self == other
end
+ def merge(other)
+ with(alternatives: alternatives.merge(other.alternatives))
+ end
+
def fetch(k, default=nil)
if (default || block_given?) && !alternatives.key?(k)
return (default || yield)
M lib/dhall/typecheck.rb => lib/dhall/typecheck.rb +2 -4
@@ 620,10 620,8 @@ module Dhall
annotated_value = @value.annotate(context)
type = Dhall::UnionType.new(
- alternatives: { @union.tag => annotated_value.type }.merge(
- @union.alternatives.alternatives
- )
- )
+ alternatives: { @union.tag => annotated_value.type }
+ ).merge(@union.alternatives)
# Annotate to sanity check
TypeChecker.for(type).annotate(context)