Commit Diff


commit - 8eb3abec5b0950622c9f530ff37437d2da2c90af
commit + e599ffc44d8133fb9bea8e8eb0d39e86079a264f
blob - b2f43cf2e93fa8afc456a7b3e14c5dab0c49d091
blob + f2e488f1a68deae8eed6c474c8bf08c28212e1cd
--- script.c
+++ script.c
@@ -217,12 +217,18 @@ global_set(char *sym, struct op *op)
 
 	/* TODO: check for duplicates */
 
-	if (op->type != OP_LITERAL)
+	if (op->type != OP_LITERAL &&
+	    (op->type == OP_CAST && op->v.cast.expr->type != OP_LITERAL))
 		return 0;
 
 	b = xcalloc(1, sizeof(*b));
 	b->name = sym;
-	memcpy(&b->val, &op->v.literal, sizeof(b->val));
+
+	/* it's only a cast on a literal! */
+	if (op->type == OP_CAST && eval(op) != EVAL_OK)
+		return 0;
+	else
+		memcpy(&b->val, &op->v.literal, sizeof(b->val));
 
 	e = TAILQ_LAST(&envs, envs);
 	TAILQ_INSERT_HEAD(&e->bindings, b, entry);