Commit f070108e authored by Stefan Behnel's avatar Stefan Behnel

fix coercion from IntNode to FloatNode, e.g. for hex literals etc.

parent 9ca148be
...@@ -815,8 +815,13 @@ class IntNode(ConstNode): ...@@ -815,8 +815,13 @@ class IntNode(ConstNode):
if self.type is dst_type: if self.type is dst_type:
return self return self
elif dst_type.is_float: elif dst_type.is_float:
float_value = float(self.value) if self.constant_result is not not_a_constant:
return FloatNode(self.pos, value=repr(float_value), constant_result=float_value) float_value = float(self.constant_result)
return FloatNode(self.pos, value=repr(float_value), type=dst_type,
constant_result=float_value)
else:
return FloatNode(self.pos, value=self.value, type=dst_type,
constant_result=not_a_constant)
node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, node = IntNode(self.pos, value=self.value, constant_result=self.constant_result,
unsigned=self.unsigned, longness=self.longness) unsigned=self.unsigned, longness=self.longness)
if dst_type.is_numeric and not dst_type.is_complex: if dst_type.is_numeric and not dst_type.is_complex:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment