Strange runtime error when comparing a name

(adv3)
I have a thing whose name whose changes twice, but the first change can be overriden if the player does a different action.

The thing is initially known as a ‘contraption’, and if examined, is revealed as a ‘piano-organ’, and when played (is a musical instrument) changes again into ‘NPC's piano organ’; of course, if the player does first playing then examining (in the realm of possible, because its nature is obvious), the name will be “downgraded”; I have done the logical coding:

if (name == 'contraption') name = 'piano-organ';

whose works as expected, aside an unexpected and baffling runtime error:

[Runtime error: invalid datatype for bitwise AND operator
]

yes, bitwise AND: I have even resorted to

grep '&' *.t

in my working directory, with no results; besides, I’m sure that I never have coded bitwise AND operator in this WIP, and there’s no stray spaces in the very few pointers.
The full verbatim code of the thing in question is below, under appropriate spoiler space:

piano: Fixture '(very) strange unusual contraption/piano/organ/piano-organ' 
'contraption' @ball
desc {
"You're puzzled by that strange contraption, and examining it carefully, 
you're surprised in discovering that it is a rather unusual musical 
instrument, nonexistant on Earth: is a combination vertical piano and organ. 
You wonder how its music sounds.";
if (name == 'contraption') name = 'piano-organ';
}

dobjFor(Play)
 {
	preCond = []
	verify() { }
	action() { "You try pressing some keys of the piano-organ, and the 
sound from it kicks <i>something</i> inside you, and you start actually 
playing it; the music is initially alien to you, but you soon realise that 
these elfin pointy ears actually have a much larger gamut of frequencies than 
human rounded ears, and you cannot avoid appreciating the marked improvement 
in musical enjoyment.\n The piece you're playing is more \"angelical\" than 
\"elfin\", and you realise that this instrument is the one played by that 
angelical girl, Miryarai.";
name = 'Miyai\'s piano-organ';
initializeVocabWith('Miryarai\'s Miyai\'s piano/organ/piano-organ');
	}
}
;

Where came that illogical runtime error ??

TIA and
Best regards from Italy,
dott. Piergiorgio.

Can’t you get a line number and source file from the RTE?

RTE ?

anyway, the same strange error happens there:

  dobjFor(Play)
 {
   verify() { }
   check() {
	if (dbow.isHeldBy(etuye) ==nil )
	  failCheck ('You can\'t play a double bass without a bow. Perhaps is 
	somewhere around...');
	}
	action() { "When you start playing this double bass-like instrument, you 
discover that pair of pointy ears you now have has a much larger gamut of 
frequencies than rounded ears, and this larger gamut raise considerely your 
appreciation of music; and also that you play the instrument with a 
<i>natural</i> aptitude, playing a definitively elfin piece, whose raise a 
warm of love in your chest; you realise that this instrument is the one you 
usually play.";

Best regards from Italy,
dott. Piergiorgio.

RTE = runtime error… do you have reflection included in your build? You should get line numbers and source files for every error…

reflection ?

ok, seems that we have different environments… This is a Linux machine, and I use Kate for editing and the good’ ol bash for compiling (t3make -f isekai.t3m in this case) and Qtads for executing & debugging.

If the files reflect.t and reflect.h are included in your build, the errors should always tell you where they occur…

They should be part of the adv3 distribution…

added that reflect.t and reflect.h

The result is definitively much less clear:

[Runtime error: invalid datatype for bitwise AND operator
–>
Runtime error: invalid index operation - this type of value cannot be indexed
-->Unhandled exception: invalid index operation - this type of value cannot be indexed

I don’t know how this can be helpful, sincerely.

dott. Piergiorgio.

BTW, the first issue is solved, moving the if from the desc to a dobjFor, inheriting the desc, that is:

dobjFor(Examine)
   {
     action()
     {
       inherited;
       changeName();
     }
   }
  changeName()
  {
    if (name == 'contraption') name = 'piano-organ';
  } 

whose works as designed & expected, without throwing bizarre errors. Remain the other, whose looks more complex, and worrisome, if there’s a major bug in IsHeld, and not a mistake on my part, is a very serious one.

Best regards from Italy,
dott. Piergiorgio.

1 Like

UPDATE: there really was bitwise AND, caused by… a repeated cut’n paste typo !

cmdDict.addWord(doubbas, 'Atuzejiki\'s' &adjective);

notice that there’s THREE parameters, but I missed the , between the second and third parameters, and all became a two-parameters call, the second being an… bitwise operator between the actual 2nd and 3rd parameter !!

Then, I have used that same wrong line as template three times, leading to the multiple throwing of runtime error !

at least this coding wasn’t a for million-dollar space probe…

3 Likes

Glad you found it! What I was trying to describe is a runtime error that shows a full stack trace, where each function call is listed with its source file and line number. I think you need reflect.t to get that much. But if the error is in preinit or a static initializer, sometimes you don’t get the stack trace and that’s probably what you were seeing. You’ll definitely want the reflectionServices for other things though!