Azazel.ash - Organ of Steel, Automated

Status
Not open for further replies.
This script broke with a recent KoLmafia change.

To fix it:
Add a new line 31, above the old one:
return true;

Similarly for what was line 36 before the above change, now 37:
return false;

The relevant adv function in the script now looks like this, for you copy-pasters:
Code:
boolean adv(location i){
if(my_adventures() >=1)
{
adventure(1, i);
return true;
}
else
{
print("NO MORE ADVENTURES!","red");
abort();
return false;
	}
}
 

Bale

Minion
Yes:

r11707 | jasonharper | 2012-12-16 05:17:54 +0000 (Sun, 16 Dec 2012) | 10 lines

Boolean functions that can exit without executing a 'return' statement are
now errors rather than warnings. You've had 9 months to fix these.
 

Winterbay

Active member
So, you need to add a warning to remove an error? Or doesn't abort() count as having things behind it be unreachable?
 

Bale

Minion
Runing this program:

PHP:
boolean binary() {
	if(true) {
		return true;
	} else {
		abort();
	}
}

void main() {
	print(binary());
}

Produces this output:

> call testing.ash

Missing return value (testing.ash, line 7)

If I add a return false after abort() as wrldwzrd89 did, the program runs fine without an unreachable code warning. Try it your own self.
 
Last edited:

fronobulax

Developer
Staff member
The parser doesn't know that abort never returns and that is reasonable behavior IMO. The fact that true is obviously and always true could be used by the parser, but the construct "if (true)" seems to have more practical application in bedeviling parsers than in actual working code. ("while (true)" is something else, entirely). Tangentially I'll express my personal preference for code that has exactly one exit or return because it is easier to follow and read.
 

Winterbay

Active member
Yes, I feel that the edited function above would be just as well looking like this:
Code:
boolean adv(location i) {
   if(my_adventures() >=1)
      adventure(1, i);
   else {
      print("NO MORE ADVENTURES!","red");
      abort();
   }
   return true;
}
 

Theraze

Active member
Why not reduce calculations by 2 and do this?
Code:
boolean adv(location i) {
   if(my_adventures() < 1)
   {
      print("NO MORE ADVENTURES!","red");
      abort();
   }
   adventure(1, i);
   return true;
}
Reduced by 1 because you don't check if my_adventures() > 1; reduced by 1 because you don't check if my_adventures() == 1. And all the executing code lives together.

Edit: Note that this adventure-check has an intrinsic weakness... it's calling adventure, which aborts if unfulfilled conditions remain and are not trapped. Because of that, we can (reasonably) expect that a 'failed' adventure is supposed to abort. And we can/should just run:
Code:
boolean adv(location i) {
   if(my_adventures() < 1)
   {
      print("NO MORE ADVENTURES!","red");
      abort();
   }
   return adventure(1, i);
}
 
Last edited:
Why not reduce calculations by 2 and do this?
Code:
boolean adv(location i) {
   if(my_adventures() < 1)
   {
      print("NO MORE ADVENTURES!","red");
      abort();
   }
   adventure(1, i);
   return true;
}
Reduced by 1 because you don't check if my_adventures() > 1; reduced by 1 because you don't check if my_adventures() == 1. And all the executing code lives together.

Edit: Note that this adventure-check has an intrinsic weakness... it's calling adventure, which aborts if unfulfilled conditions remain and are not trapped. Because of that, we can (reasonably) expect that a 'failed' adventure is supposed to abort. And we can/should just run:
Code:
boolean adv(location i) {
   if(my_adventures() < 1)
   {
      print("NO MORE ADVENTURES!","red");
      abort();
   }
   return adventure(1, i);
}
I like your thinking Theraze. I've made the relevant edit to my copy of the script. Thanks! ;)
 
Fixes for location changes:


Change "Hey Deze Arena" to "Infernal Rackets Backstage"

Change "Belilafs Comedy Club" to "The Laugh Floor"
 

zopiate

New member
I'm getting the following after I load the script:

> call scripts\Azazel.ash
Missing return value (Azazel.ash, line 37)
 
Status
Not open for further replies.
Top