Bugzilla – Bug 4266
Pointless compiler warning
Last modified: 2013-07-04 13:29:42 PDT
Hi, since I could not find Compiler 'Component' I put it to Core. Please do move it if I made a mistake. To the point: AMXX compiler should be more "smarter". This code returns compile warning: Code: if(someBoolVar) { return PLUGIN_CONTINUE } else { return PLUGIN_HANDLED } Warning: warning 209: Function "someFunction" should return a value. As you see function returns value depending on branch. So compiler should check if both branches return value and conclude based on that should or should not return a warning. Thanks for reading.
Additionally if one or more branches don't return a value it should raise "Function ... doesn't return value on every branch" warning.
Could you give a better description of the semantics in comment #1? Any solution that breaks existing code is not good - and taken strictly, it seems like it would break this: I don't understand comment #1 - it seems like it would break this perfectly valid, existing code: f() { if (expression) return 1 else g() return 1 } Even missing the "return 1", this is valid code, since Pawn's semantics have an implicit "return 0" (not saying I agree with this, however - I think it already warns).
Code is: f() { if(something) return 1 else return 2 } Warning is that function f should return a value. Function returns value in one of if branches. Clearer?