~lbnz/xr0

8badd6f79e894acae96a4253289793069fcc6831 — Amisi Kiarie a month ago 429d6ab fix/props-get-hack v0.15.3
fix: conditional allocation test should have failed

resolves: https://github.com/xr0-org/xr0/issues/50
4 files changed, 31 insertions(+), 4 deletions(-)

M src/props/props.c
R tests/1-branches/{0301-conditional-allocation-two.x => 0301-FAIL-conditional-allocation-two.x}
A tests/1-branches/0301-FAIL-conditional-allocation-two.x.EXPECTED
A tests/1-branches/0302-conditional-allocation-two.x
M src/props/props.c => src/props/props.c +0 -4
@@ 77,10 77,6 @@ props_install(struct props *p, struct ast_expr *e)
bool
props_get(struct props *p, struct ast_expr *e)
{
	/* XXX: hack for shallow not conditions, fix in TODO */
	if (ast_expr_isnot(e)) {
		return !props_contradicts(p, e);
	}
	for (int i = 0; i < p->n; i++) {
		/* TODO: logical comparison */
		if (ast_expr_equal(e, p->prop[i])) {

R tests/1-branches/0301-conditional-allocation-two.x => tests/1-branches/0301-FAIL-conditional-allocation-two.x +5 -0
@@ 1,3 1,8 @@
/* 
 * thanks to jorendorff
 * https://github.com/xr0-org/xr0/issues/50
 */

#include <stdlib.h>

void *

A tests/1-branches/0301-FAIL-conditional-allocation-two.x.EXPECTED => tests/1-branches/0301-FAIL-conditional-allocation-two.x.EXPECTED +1 -0
@@ 0,0 1,1 @@
test | $0 | !(!($1)): actual and abstract states differ

A tests/1-branches/0302-conditional-allocation-two.x => tests/1-branches/0302-conditional-allocation-two.x +25 -0
@@ 0,0 1,25 @@
/* 
 * thanks to jorendorff
 * https://github.com/xr0-org/xr0/issues/50
 */

#include <stdlib.h>

void *
test(int x, int y) ~ [
	if (x) {
		return .malloc(1);
	} else if (y) {
		return NULL;
	} else {
		return .malloc(1);
	}
]{
	if (x) {
		return malloc(1);
	}
	if (!y) {
		return malloc(1);
	}
	return NULL;
}