Improve implicit casts from static arrays to sets

Issue #10 new
Eric Grange repo owner created an issue

Based on https://bitbucket.org/egrange/dwscript/pull-request/4/enhancement-to-set-type/diff

  • cast for typed assignment in const/var initialization
  • cast during overload resolution

During overload resolution, an ambiguity needs to be lifted if there are multiple matching sets for a given set of values, will require a metric.

type TMyEnum = (meOne, meTwo);
type TMySet = set of TMyEnum;

var VarSet: TMySet = [meOne];
const ConstSet: TMySet = [meOne]; // Syntax Error: Incompatible types: "TMySet" and "array [0..0] of TMyEnum"

procedure Test(MySet: TMySet); overload; // Handled by compiler as overload even though there's only one
begin
end;

begin
  Test([meOne]); // Syntax Error: There is no overloaded version of "Test" that can be called with these arguments
end;

Comments (0)

  1. Log in to comment