~lbnz/xr0

6d5f7614cc60da55e5c2a4d62cfd6db1df791c7d — Xr0 Team 4 months ago 3ee240d feat/param-constraints
added test case
M src/0v/ast/expr/verify.c => src/0v/ast/expr/verify.c +5 -0
@@ 738,6 738,11 @@ expr_assign_eval(struct ast_expr *expr, struct state *state)
		free(s);
		return result_error_create(error_create(strbuilder_build(b)));
	}
	struct value *val = object_as_value(obj);
	while (val && value_islocation(val)) {
		obj = state_deref(state, val, ast_expr_constant_create(0)); 	
		val = object_as_value(obj);
	}
	object_assign(obj, value_copy(result_as_value(res)));
	return res;
}

M src/0v/value/value.c => src/0v/value/value.c +1 -0
@@ 545,6 545,7 @@ value_str(struct value *v)
bool
value_islocation(struct value *v)
{
	assert(v);
	return v->type == VALUE_PTR && !v->ptr.isindefinite;
}


A tests/0-basic/210-stack-scope-aware.x => tests/0-basic/210-stack-scope-aware.x +20 -0
@@ 0,0 1,20 @@
#include <stdlib.h>

void *
assign(void *p) ~ [
	*p = 1;
] {
	/* TODO: internal verification */
	*p = 1;
}

int
main() {
	int q;
	int p;

	assign(&q);
	p = 2;	

	~ [ q == 1; p == 2; ]
}

M tests/5-preconditions/000-basic.x => tests/5-preconditions/000-basic.x +0 -5
@@ 31,11 31,6 @@ main()
	puts("Enter y: ");
        scanf("%d", &y);
	
	if (y == 0) {
		puts("Cannot divide by 0");
		return NULL;
	}

	r = ratio(x, y);

	/* use sprintf to convert int to string */