This should make it clear:
someobject
proc
this_can_be_anything()
world << "This is never going to compile..."
proc
ConfuseTheParser()
var/someobject
animate = new /someobject
text = new /someobject
file = new /someobject
list = new /someobject
browse = new /someobject
icon = new /someobject
image = new /someobject
orange = new /someobject
min = new /someobject
max = new /someobject
roll = new /someobject
stat = new /someobject
view = new /someobject
//etc.
// This is the part where the compiler gets mad!
animate.this_can_be_anything()
text.this_can_be_anything()
file.this_can_be_anything()
list.this_can_be_anything()
browse.this_can_be_anything()
icon.this_can_be_anything()
image.this_can_be_anything()
orange.this_can_be_anything()
// You can just forget about eating any oranges!
min.this_can_be_anything()
max.this_can_be_anything()
roll.this_can_be_anything()
stat.this_can_be_anything()
// No stats for you!
view.this_can_be_anything()
Where you try to access the method, the compiler will throw "invalid expression" errors. It will also throw "variable defined but not used" warnings.
All of this should clearly be valid code that compiles, but it doesn't. There is some kind of bug in the parser that is ignoring everything between the dot and the left parenthesis.
Below is the original bug report for reference (List procs are not compiling when the var name is "list".):
Descriptive Problem Summary:
I have always felt paranoid about using the list procs and now I know why! I was encountering a bug without realizing it. This bug is present in the earliest build available, which is very surprising to me. How could such an obvious bug go without being fixed for years?
In reality, you cannot use any list procs for a list var when it is literally named "list". For example, list.Cut() doesn't actually work. When the name of the var is "list", list procs just don't compile, and the compiler throws invalid expression errors.
Numbered Steps to Reproduce Problem:
1. Create a new project and add the following code:
mob
verb
testcutlst() // works
var/list/lst = list("a", "b", "c")
var/pos = lst.Find("b", 1, 0)
lst.Cut(pos, pos + 1)
src << "[lst[1]]"
src << "[lst[2]]"
/*
testcutlist() // doesn't work
var/list/list = list("a", "b", "c")
var/pos = list.Find("b", 1, 0)
list.Cut(pos, pos + 1)
src << "[list[1]]"
src << "[list[2]]"
*/
2. Compile, run, click the testcutlst verb, and see that it works.
3. Uncomment the code for testcutlist() and try to compile.
4. Check for the invalid expression errors that are thrown.
Expected Results:
Naming a var "list" has no effect on compilation.
Actual Results:
Trying to call the list procs of a list var named "list" results in invalid expression compiler errors.
Does the problem occur:
Every time? Or how often?
It seems to occur every time.
In other games?
This might have been game breaking if the bug was not present in much older BYOND builds.
In other user accounts?
Definitely.
On other computers?
Yes.
When does the problem NOT occur?
It always occurs.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
The bug is present in builds as early as 354, and it doesn't seem to have ever been fixed after that. I can imagine that there might have been a much earlier build that didn't have the bug, but I have no access to any builds earlier than 354.
Workarounds:
Just don't use "list" for a variable name.
list is a reserved word for something special in DM, being the /list object. Trying to define it as something else is going to cause problems internally, and so BYOND just doesn't let you confuse it by throwing reserved words around in it all willy-nilly.
Granted it can be rather ambiguous, and not being a programmer in any right I personally don't get why the following would happen, again I'm sure Lummox can clarify if I'm wrong.
The way I see it, if we shouldn't use list as a variable name, it should just flat-out not let us do it under any circumstance, not only when we're using specific functions.
Regardless, it gets chalked up to proper programming habits. Personally a variable shouldn't reflect its type but what the variable contains or represents, ie: list/letters = list("a", "b", "c") or list/numbers = list(1, 2, 3). Using this approach I've never come across any problems with the language.