SpacemanDMM icon indicating copy to clipboard operation
SpacemanDMM copied to clipboard

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

Open ZeWaka opened this issue 5 years ago • 7 comments

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

ZeWaka avatar May 28 '19 17:05 ZeWaka

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

spookydonut avatar Jan 17 '20 07:01 spookydonut

I'm guessing something like

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

Cyberboss avatar Jan 17 '20 16:01 Cyberboss

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

SpaceManiac avatar Jan 18 '20 01:01 SpaceManiac

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))

SpaceManiac avatar Jan 18 '20 01:01 SpaceManiac

/mob
    var/foo
    var/list/L = list()

/mob/proc/foo()
    for(src.foo in src.L)
        world.log << foo

spookydonut avatar Jan 22 '20 06:01 spookydonut

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

Cyberboss avatar Apr 09 '20 23:04 Cyberboss

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

SpaceManiac avatar Apr 09 '20 23:04 SpaceManiac