class Dhall::TypeChecker::OperatorRecursiveRecordMerge

Public Class Methods

new(expr) click to toggle source
# File lib/dhall/typecheck.rb, line 302
def initialize(expr)
        @expr = expr
        @lhs = TypeChecker.for(expr.lhs)
        @rhs = TypeChecker.for(expr.rhs)
end

Public Instance Methods

annotate(context) click to toggle source
# File lib/dhall/typecheck.rb, line 308
def annotate(context)
        annotated_lhs = @lhs.annotate(context)
        annotated_rhs = @rhs.annotate(context)

        type = annotated_lhs.type.deep_merge_type(annotated_rhs.type)

        TypeChecker.assert type, Dhall::RecordType,
                           "RecursiveRecordMerge got #{type}"

        # Annotate to sanity check
        TypeChecker.for(type).annotate(context)

        Dhall::TypeAnnotation.new(
                value: @expr.with(lhs: annotated_lhs, rhs: annotated_rhs),
                type:  type
        )
end