ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

if [variant] in [array of integer] gives incompatible type error #462

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
var list: array of integer = [5, 7];
var item: variant = 5;
if item in list then
   print('success')
else print('fail');

By definition, variant is supposed to be compatible with any type, but the 
compiler gives an incompatible types error.

Original issue reported on code.google.com by masonwhe...@gmail.com on 7 Apr 2014 at 12:19

GoogleCodeExporter commented 8 years ago
Delphi gives a similar error in some cases like

   var v : Variant;
   ...
   if v in [1,2] then ...

but we can do better :)

Added conversion for the common cases.

Original comment by zar...@gmail.com on 7 Apr 2014 at 7:10