are there 5 ?
3.14159 I like Pie but The cake is a lie
+Test merging of variables from multiple cases
+
+###### test list
+ oceani_tests += varmerge
+
+###### test: varmerge
+
+ program:
+ for i:=0; then i=i+1; while i < 5:
+ switch i
+ case 0: num:="zero"
+ case 1: num:="one"
+ case 2: num:="two"
+ case 3: num:="three"
+ else: num:="many"
+ print num,", ",
+ print
+
+###### output: varmerge
+ zero , one , two , three , many ,
+
## Conditions and Loops
Now we need to test if/else and some different loops
switch (v ? v->scope : OutScope) {
case OutScope:
case PendingScope:
- /* Signal an error - once that is possible */
+ /* Caller will report the error */
return NULL;
case CondScope:
/* All CondScope variables of this name need to be merged
static void var_block_close(struct parse_context *c, enum closetype ct)
{
- /* close of all variables that are in_scope */
+ /* Close off all variables that are in_scope */
struct variable *v, **vp, *v2;
scope_pop(c);
for (vp = &c->in_scope;
v = *vp, v && v->depth > c->scope_depth && v->min_depth > c->scope_depth;
) {
- switch (ct) {
+ if (v->name->var == v) switch (ct) {
case CloseElse:
case CloseParallel: /* handle PendingScope */
switch(v->scope) {
}
break;
}
- if (v->scope == OutScope)
+ if (v->scope == OutScope || v->name->var != v)
*vp = v->in_scope;
else
vp = &v->in_scope;