HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Another return bug found?

04-16-2004, 05:51 AM#1
Cacodemon
Yesterday I found another JASS compiler bug:

Code:
// Another JASS compiler bug.

function MyFunc takes integer IntArg, unit UnitArg, player PlrArg returns nothing
endfunction

function BuggyFunc takes nothing returns boolean
 local trigger MyTrig = CreateTrigger()
 local force MyForce = null
 local group MyGroup = null
 //
 // ...
 //
 // Bugzzz...
 call TriggerAddAction(MyTrig, function MyFunc)
 call ForForce(MyForce, function MyFunc)
 call ForGroup(MyGroup, function MyFunc)
 return true // When being placed before 'Bugzzz' comment, this string causes compiler errors to appear again.
endfunction

// Yes, compiler saves this buggy code  o_O 

Functions defined with arguments can be passed as code-type parameters into enum functions, TriggerAddAction() etc. when being placed before return in parent function. If no return operator exists after these "buggy" calls, compiler errors appear again.

I cant' guess usage of this bug and I have no time to test it in game, but this bug seems to be interesting and I hope it can be useful as well as return bug.
04-16-2004, 11:52 AM#2
jmoritz
Code:
native ForForce                 takes force whichForce, code callback returns nothing
native ForGroup                 takes group whichGroup, code callback returns nothing
native TriggerAddAction     takes trigger whichTrigger, code actionFunc returns triggeraction

As you can see, they all take 'code' as callback. You create a code object using the function operator: 'local code x = function myfunc'. There's nothing about parameter and return types of 'code' objects at jass.sourceforge.net, pjass compiles the code, and so does war3, even without the return statement. If you actually run the code in war3, war3 simply crashes (the function tries to put the parameter into a local variable, which it can't).
04-17-2004, 03:55 PM#3
Vexorian
The compiler gives me error messages with your map