~sircmpwn/harec unlisted

0bd9f47f650e1c9e01a151bf2f2d1e633543d9a3 — Eyal Sawady a month ago e223815
eval_cast: fix float -> integer casts

Signed-off-by: Eyal Sawady <ecs@d2evs.net>
1 files changed, 9 insertions(+), 1 deletions(-)

M src/eval.c
M src/eval.c => src/eval.c +9 -1
@@ 414,7 414,15 @@ eval_cast(struct context *ctx, struct expression *in, struct expression *out)
	case STORAGE_UINTPTR:
	case STORAGE_SIZE:
	case STORAGE_RUNE:
		out->constant.uval = itrunc(to, val.constant.uval);
		if (type_is_float(val.result)) {
			out->constant.ival =
				itrunc(to, (intmax_t)val.constant.fval);
		} else if (type_is_signed(val.result)) {
			out->constant.ival = itrunc(to, val.constant.ival);
		} else {
			assert(type_is_integer(val.result));
			out->constant.ival = itrunc(to, val.constant.uval);
		}
		return EVAL_OK;
	case STORAGE_ARRAY:
	case STORAGE_SLICE: