SpaceManiac / SpacemanDMM

A BYOND language smartness provider, map renderer, and more.
https://marketplace.visualstudio.com/items?itemName=platymuus.dm-langclient
GNU General Public License v3.0
83 stars 83 forks source link

Error on valid for(object.thing1 in object.listofthings) #82

Open ZeWaka opened 5 years ago

ZeWaka commented 5 years ago

Error: for-list must start with variable

It doesn't need to in the case of for (thing1 in thinglist)

It'll just iterate how many times thing1 is in thinglist.

https://github.com/SpaceManiac/SpacemanDMM/blob/7baf6dea13c2f58cbc0faeb250b586e30e355b55/src/dreammaker/parser.rs#L1134

spookydonut commented 4 years ago

@ZeWaka Can you give a minimal example of code that triggers this? I can't replicate the error

Cyberboss commented 4 years ago

I'm guessing something like

var/list/L = list("1", "0", "0", "1", "1", "0", "1")
for("1" in L)
  //runs 4 times
SpaceManiac commented 4 years ago

@Cyberboss doesn't compile in DM, so I'm not sure where you are going with it

SpaceManiac commented 4 years ago

I'm noting this because it's related, but I don't want it "fixed". Found on Polaris, considered dead code and eliminated by DreamMaker, and thus nonsense that SpacemanDMM should error on.

for(1 to rand(1, 3))
    laws.add_ion_law(generate_ion_law(exclude_crew_names = TRUE))
spookydonut commented 4 years ago
/mob
    var/foo
    var/list/L = list()

/mob/proc/foo()
    for(src.foo in src.L)
        world.log << foo
Cyberboss commented 4 years ago

@SpaceManiac is that for(1 to X) issue a separate issue orrrr?

SpaceManiac commented 4 years ago

for(1 to X) is nonsense and should error, it doesn't really matter how The feature request in this ticket is that for(multipronged.lvalue.expression in L) should parse