Possible [for] bug, 1.13.8

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Samonella
Posts: 374
Joined: January 8th, 2016, 5:41 pm
Location: USA

Possible [for] bug, 1.13.8

Post by Samonella » June 20th, 2017, 9:21 pm

If I understand it right from the wiki, this should be perfectly valid code, iterating from 0 to 3:

Code: Select all

	[for]
		end=3
		[do]
			< stuff >
		[/do]
	[/for]
But it results in this error:

Code: Select all

error scripting/lua: lua/wml-flow.lua:149: attempt to perform arithmetic on a nil value (field 'step')
stack traceback:
	lua/wml-flow.lua:149: in local 'cmd'
	lua/wml-utils.lua:145: in field 'handle_event_commands'
	lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
	[C]: in field 'fire_event'
	lua/wml-tags.lua:146: in local 'cmd'
	lua/wml-utils.lua:145: in field 'handle_event_commands'
	lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
So I tried adding step=1 in the code, and then it worked fine. According to the wiki, 'step' should default to 1 (or -1, based on 'start' and 'end') so this is a bug?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG

Tad_Carlucci
Developer
Posts: 439
Joined: April 24th, 2016, 4:18 pm

Re: Possible [for] bug, 1.13.8

Post by Tad_Carlucci » June 21st, 2017, 12:23 am

Try this:

In wesnoth's data/lua/wml-flow.lua change line 102 from

Code: Select all

		if cfg.step then loop_lim.step = cfg_lit.step end
to

Code: Select all

		if cfg.step then loop_lim.step = cfg_lit.step else loop_lim.step = 1 end
and retest.
I forked real life and now I'm getting merge conflicts.

User avatar
Samonella
Posts: 374
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Possible [for] bug, 1.13.8

Post by Samonella » June 21st, 2017, 1:09 am

That seems to have fixed it, at least for end>start. Thanks!
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG

Tad_Carlucci
Developer
Posts: 439
Joined: April 24th, 2016, 4:18 pm

Re: Possible [for] bug, 1.13.8

Post by Tad_Carlucci » June 21st, 2017, 1:14 am

OK. If Celtic Minstrel doesn't beat me to it, I'll put together a PR with a more-complete solution.
I forked real life and now I'm getting merge conflicts.

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Possible [for] bug, 1.13.8

Post by zookeeper » June 21st, 2017, 9:29 am

5fdb73b9 was supposed to fix this exact issue, but I guess he didn't test it? :whistle:

Tad_Carlucci
Developer
Posts: 439
Joined: April 24th, 2016, 4:18 pm

Re: Possible [for] bug, 1.13.8

Post by Tad_Carlucci » June 21st, 2017, 6:33 pm

PR #1812 is the fix above. On reading the code, the case where 'end=-3' should do nothing with the wiki-specified default of 'step=1' so no additional checks seemed to be needed.
I forked real life and now I'm getting merge conflicts.

User avatar
WhiteWolf
Forum Regular
Posts: 557
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Possible [for] bug, 1.13.8

Post by WhiteWolf » August 31st, 2019, 9:13 pm

original post:
EDIT: Sorry, it was my bad. One of the macros inside the [do] also used a variable named i and that caused the conflict.
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

Post Reply