Changeset: a1bf0b59ae79 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a1bf0b59ae79
Modified Files:
monetdb5/mal/mal_function.mx
Branch: Apr2011
Log Message:
The first time we see a variable, if it's already initialized, assume it's a
global.
The very first thing Mtest.py does when it starts testing is to send
the MAL plan:
c := mdb.modules();
mods := algebra.kunique(c);
s := "\nModules: ";
sep := "";
barrier (mloop:lng,h:int,t:str) := bat.newIterator(mods);
s := s + sep;
s := s + "'";
s := s + t;
s := s + "'";
sep := ",";
redo (mloop:lng,h:int,t:str) := bat.hasMoreElements(mods);
exit mloop;
s := s + "\n";
io.printf(s);
clients.quit();
This caused the following error on the line following the exit:
!TypeException:user.main[1]:'s' may not be used before being initialized
The reason for this was that when the function chkDeclarations() is
called to check the loop, it clears the initialized state for s (and
sep) at the end of the loop because loop bodies are optionally
executed (and so the assignments in the loop may not have happened),
even though they were already initialized when the loop started. The
patch makes that this clearing doesn't happen by assuming that when a
variable is encountered for the first time and it was already
initialized, it is global.
diffs (15 lines):
diff --git a/monetdb5/mal/mal_function.mx b/monetdb5/mal/mal_function.mx
--- a/monetdb5/mal/mal_function.mx
+++ b/monetdb5/mal/mal_function.mx
@@ -911,6 +911,11 @@
/* define variables */
for(k=0; k<p->retc; k++){
l= getArg(p,k);
+ if (isVarInit(mb, l) && decl[l] == 0) {
+ /* first time we see this variable and it is
already
+ * initialized: assume it exists globally */
+ decl[l] = blks[0];
+ }
setVarInit(mb,l);
if( decl[l] == 0){
/* variable has not been defined yet */
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list