Conversion from int to bool fails
|
|
Bugzilla Link |
575 |
Created on |
Oct 23, 2009 14:20 |
Resolution |
INVALID |
Resolved on |
Oct 23, 2009 14:38 |
Version |
1.00beta |
OS |
Linux |
Architecture |
PC |
Extended Description
If we are trying to convert int to bool, like in example:
module err;
export all;
int f(int x) {
return (x);
}
bool g() {
boolRes = (:bool)f(1);
return (boolRes);
}
Compiler complains that the right-hand-side of the assignment is still int.
ERROR: line 9 file: err.sac
ERROR: All instances of "g" contain type errors
ERROR: line 10
ERROR: Element types of cast-type and expr-type should be identical; types
ERROR: found: bool and int
ERROR: line 11
ERROR: inferred type int should match declared type bool
*** Compilation failed ***
*** Exit code 42 (Running type inference system)
*** 2 Error(s), 0 Warning(s)
Compiler version:
sac2c v1.00-beta (Buchette d'Anjou)
developer rev 16483 linux-gnu_i686
(Mon Oct 19 09:24:55 BST 2009 by asv)