Explorer

core.type-check-function-call

description
Type-check a call of a function type: infer the type arguments that are not entered (with the expected type of the call if any), substitute the type arguments and check the arguments
type
Fn(
  function_type: Record{parameters: List<Record{name: String, type: @core.type-ast}>, return_type: @core.type-ast},
  arguments: List<Record{name: String, value: @core.expression}>,
  env: @core.type-env,
  expected_type: Union{#none, #some(@core.type-ast)}
) -> @core.type-result
expression
fn(function_type$0, arguments$1, env$2, expected_type$50) =>
  match @core.type-call-type-arguments(
      parameters: $0.parameters,
      arguments: $1,
      env: $2,
      index: 0,
      accum: [],
      return_type: $0.return_type,
      expected_type: $50
    ) {
    #error(error$3) =>
      #error($3),
    #ok(type_arguments$4) =>
      match @core.equal(left: @core.list-length(value: $4), right: 0) {
        true =>
          @core.type-check-call-arguments(parameters: $0.parameters, arguments: $1, env: $2, index: 0, return_type: $0.return_type),
        false =>
          @core.type-check-call-arguments(
            parameters: @core.type-substitute-parameters(parameters: $0.parameters, arguments: $4, index: 0, accum: []),
            arguments: $1,
            env: $2,
            index: 0,
            return_type: @core.type-substitute(type: $0.return_type, arguments: $4)
          )
      }
  }
visibility
public
core.type-check-function-call (project definy, branch compiled-tests, snapshot i6TqClmqVS9FK8rKOvJ43l6Tevx8pvYJ5-zaQqNwemc)
id: ggIv7r8eKNQ6pRtMEDUKX1oKPa6K-rtiWq-snFAuQlM
content hash: haKzb5U5B2yFBDo5xN9ILSaTM6MngxkyqwZi-B2iT28