y.lagarde Posted August 28, 2015 Share Posted August 28, 2015 Hi,I just found a strange behaviour with the unigineScript compilation. Indeed i was using this function : int getId() { log.message("getId"); return m_id } like you can see, i forget a ';' at the end of my return but the compiler don't crash at all in this situation.But if I write int getId() { log.message("getId") return m_id } I've got a parser::expectSymbol() message box and can't load the world.this is normal or is it a bug ?Thx. Link to comment
silent Posted September 1, 2015 Share Posted September 1, 2015 Hi Yann, What SDK version are you currently using? With the latest 2.0 RC even the first code variant is not compiling: return m_id unigine_project/unigine_project.cpp:6: Interpreter::parse_expression(): unknown token "m_id" in "m_id" expression As for the second case - I think this is correct behavior, because you can see the line of code with the error. The compiler says that instead of ";" you got r (the first letter of the return statement). I would recommend you to always put semicolon after the return statement to avoid any other errors. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
y.lagarde Posted September 2, 2015 Author Share Posted September 2, 2015 Hi,I'm on the r1818 in DX11 using debug launch.I know that the second case is the normal behaviour, it's why I post this thread... And for you first compiling error, the message is about tha fact that "m_id" is not an declared object...So i still have normal compiling with the code : int getId() { int m_id = 1; log.message("getId"); return m_id } Ans it's only on a return.For exemple : int getId() { int m_id = 1; log.message("getId"); return m_id; } is compiling (normal) int getId() { int m_id = 1; log.message("getId") return m_id } is not compiling (normal) int getId() { int m_id = 1; log.message("getId"); return m_id } compiling ?! (not normal) int getId() { int m_id = 1; log.message("getId"); break } not compiling (normal)I only asking why the compiling let accept such writing. It is not fatal but it could create bad habit for junior programmer.Thx. Link to comment
silent Posted September 2, 2015 Share Posted September 2, 2015 Hi Yann, Not it is more clear to me, thanks for the additional information. I will surely pass this information to the developers. Maybe there is some kind of additional behavior only for return statement, so right now it is allowed not to put semicolon after it. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
silent Posted September 7, 2015 Share Posted September 7, 2015 Hi Yann, I've asked dev team and they said that it is not a bug. return statement can be used without a semicolon. So, in your examples: int getId() { int m_id = 1; log.message("getId"); return m_id } compiler will think that this code is valid. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
ulf.schroeter Posted September 7, 2015 Share Posted September 7, 2015 https://developer.unigine.com/forum/topic/3474-parser-bug-in-if-exppression/?p=18389 I could link hundreds of similar posts in the past regarding Unigine script language/interpreter problems....of dreaming of all the cool rendering features, which could have been implemented with all the energy spend for Unigibe script bug fixing... :) Link to comment
y.lagarde Posted September 7, 2015 Author Share Posted September 7, 2015 I think you are off topic. Link to comment
Recommended Posts