Bug in AS 2.14.1 script struct temporary assignment expression value

Started by
6 comments, last by WitchLord 15 years, 5 months ago
The expression value of the result of assigning a temporary to a script struct seems to be funky in AngelScript 2.14.1. Ex:

class MyClass {
  int a;
  MyClass(int a) { this.a = a; }
  int foo() { return a; }
}

void main() {
  MyClass m(5);
  int i = (m = MyClass(10)).a;
  print(i + "\n");           // prints 1804132792
  MyClass n(10);
  MyClass o(15);
  m = n = o;                 // works
//  m = n = MyClass(20);     // assert error in as_scriptstruct.cpp line 403
  (m = n).foo();             // works
//  (m = MyClass(20)).foo(); // access violation
}
This seems to occur not only with using MyClass(a) to create a temporary, but also if the temporary is the return value of a function.
Advertisement
Thanks for the detailed report. I'll look into this as soon as possible.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've found and fixed this bug. The fix will be available in the SVN in a few hours.

This bug has been around for years. It's funny how some bugs can live within the code for so long without anyone encountering them.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

The fix is in the SVN now. Let me know if you discover anything else.

Thanks.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Well one weird thing I noticed, though it doesn't cause any crashes, is that AngelScript accepts hexadecimal literals starting with any character from 0-9. Ex: 9xf and 0xf are both hexadecimal literals for the number 15. Is this deliberate?

(Right now I'm looking at implementing intellisense in my AngelScript debugger, which is why I've been looking all these parsing details lately.)
That would be a bug. Only 0x and 0X should be accepted for hex literals.

One of the things that I have planned for 2.15.0 is to expose a function that will return the token found in a string. The function will also classify this token, e.g. identifier, constant, comment, etc. Perhaps that may be of use for your intellisense implementation.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

So it'd basically just expose the functionality in as_tokenizer.h? I'm already accessing that. :)
Yes, that's the idea :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement