Jump to content
  • Advertisement
Sign in to follow this  
SiCrane

Bug in AS 2.14.1 script struct temporary assignment expression value

This topic is 3689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!