Skip to content

Ambiguous overload in call to deopt #331

Closed

Description

@marcovc

Hi,

I'm trying to make sure the recently added opt float vars are correctly implemented, but found this regarding the integer opt vars on the way, so I'm opening this separate issue:

var 1..2: x;
var bool: y;
var 1..2: f;
constraint f = if y then x else <> endif;

throws a compiler error

  in binary '=' operator expression
  in if-then-else expression
  /home/marco/tmp/libminizinc/share/minizinc/std//builtins.mzn:891:
  in call 'fzn_if_then_else_var_opt_int'
  /home/marco/tmp/libminizinc/share/minizinc/std//fzn_if_then_else_var_opt_int.mzn:5:
  in binary '/\' operator expression
  in call 'fzn_if_then_else_var_int'
  in array comprehension expression
    with i = 2
  in call 'deopt'
  ambiguous overloading on return type of function

I can't understand the problem since overloading resolution is top-down, fixing <> to "var int".

Activity

  1. marcovc commented on Oct 17, 2019

    @marcovc
    ContributorAuthor

    Oh actually I understand the problem now. Seems hard to solve. Can we have a deopt_int ? :)

  2. marcovc commented on Oct 17, 2019

    @marcovc
    ContributorAuthor

    This is a smaller example (it's what fzn_if_then_else_var_opt_int.mzn is trying to do):

    array[1..2] of var opt int: x = [1,<>];
    array[1..2] of var int: dx = [deopt(xi) | xi in x];
    

    gives:

    in variable declaration for 'dx'
      in array comprehension expression
        with xi = <>
      in call 'deopt'
      ambiguous overloading on return type of function
    
  3. added a commit that references this issue on Nov 25, 2019
    f9dbdfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions