plaidgroup / plaid-lang

The Plaid Programming Language Tools
11 stars 1 forks source link

Writing to global variables leads to generation of erroneous code #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

var global = 5;

method main() {
    global = 23;
}

What is the expected output? What do you see instead?

The Plaid compiler accepts this program but the resulting Java code is 
erroneous. The problem is that the compiler silently assumes the existence 
of a this object which isn't available in this context. I'm not sure if 
writing to global variables is actually allowed in Plaid but if it isn't 
the compiler should print an error message. Read-only accesses, e.g. 
printing the global variable, work flawlessly.

Original issue reported on code.google.com by manuelmohr@gmail.com on 31 May 2010 at 11:48

GoogleCodeExporter commented 9 years ago
Yes, this should work and needs to be fixed.

Original comment by mhahn...@gmail.com on 1 Jun 2010 at 2:44

GoogleCodeExporter commented 9 years ago

Original comment by manuelmohr@gmail.com on 1 Jun 2010 at 2:48

GoogleCodeExporter commented 9 years ago
Should be fixed. By the way, the IDList container has the strangest semantics 
ever 
because add() does not change the current container but just returns a new 
IDList 
with the new element added at the end of the list. Maybe we should change that 
;)

Original comment by manuelmohr@gmail.com on 1 Jun 2010 at 9:50

GoogleCodeExporter commented 9 years ago
Writing to non-existent global variables still generates wrong Java code 
because we 
don't check if the variable in question really exists at the moment. I'll just 
reopen this issue and take a look at it.

Original comment by manuelmohr@gmail.com on 2 Jun 2010 at 1:52

GoogleCodeExporter commented 9 years ago

Original comment by manuelmohr@gmail.com on 2 Jun 2010 at 3:21

GoogleCodeExporter commented 9 years ago
New scoping system fixed this.

Original comment by manuelmohr@gmail.com on 10 Jun 2010 at 7:05