Page 1 of 1

Syntax check not aware of compiler conditionals (bug ??)

Posted: Sat Mar 28, 2015 3:34 pm
by Blue
With the following simpleton of program :

Code: Select all

Procedure this_is_OK()
  ProcedureReturn 1
EndProcedure

Procedure Do_This()
  Debug "busy doing this"
EndProcedure

CompilerIf #PB_Compiler_Debugger
  Procedure And_That()
    Debug "...and that, as well"
  EndProcedure
CompilerEndIf

If this_is_OK()
  Do_This()
  And_That()
EndIf

End
and with the debugger ON
(1) If you compile/run, the above code works fine
(2) If you run a syntaxCheck, you get an error message; i was expecting the syntax check to report the same result as the compiler.

Is this the expected behaviour ?
Or should it be reported as a bug ?

 

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sat Mar 28, 2015 4:36 pm
by NicknameFJ
How should syntax check know the constants setting which are made by the IDE when starting the compiling? No bug.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sat Mar 28, 2015 5:37 pm
by Tenaja
What this clearly demonstrates (in my view) is the debugger is NOT enabled during Syntax Check.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sat Mar 28, 2015 7:25 pm
by StarBootics
To do something like this you have to tihs

Code: Select all

Procedure this_is_OK()
	ProcedureReturn 1
EndProcedure

Procedure Do_This()
  Debug "busy doing this"
EndProcedure

CompilerIf #PB_Compiler_Debugger
  Procedure And_That()
    Debug "...and that, as well"
  EndProcedure
CompilerEndIf

If this_is_OK()
  
  Do_This()
  
  CompilerIf #PB_Compiler_Debugger
    And_That()
  CompilerEndIf
  
EndIf

End


Best regards
StarBootics

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sat Mar 28, 2015 8:13 pm
by luis
Blue wrote: Is this the expected behaviour ?
Who knows.
If the syntax check is supposed to do exactly the same thing as "Create executable" minus the actual EXE generation, then yes.

But AFAIK it's not explicitly documented as such so your opinion is good as any.
Uhm... actually it's not documented at all where you would expect it to be: http://www.purebasic.com/documentation/ ... piler.html
I think we may assume the current behavior is the intended one, since "Create executable" also ignores the debugger setting and always create a release build, and your code is rather strange since it's not compilable in release mode.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 1:19 am
by Dude
NicknameFJ wrote:How should syntax check know the constants setting which are made by the IDE when starting the compiling?
Why should it? It's meant to be just checking the syntax of each line; not the constant values. I agree it's a bug.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 10:36 am
by NicknameFJ
@Dude

I don't know if I understood you right.

You said syntax checking just do a syntax check of each line and not checking the value of the constants. I agree 100% with that.

You quoted me: "How should syntax check know the constants setting which are made by the IDE when starting the compiling?"

and than you say that you agree: "It´s a bug". I never said / meant that it is a bug. I said it´s not a bug and i meant it´s not a bug because syntax checking does just checking the syntax like you did.

So I don't undersand why you say it's a bug. Or is it a typo? And you meant it's not a bug like I did?

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 11:44 am
by Dude
NicknameFJ wrote:I never said / meant that it is a bug.
But you did ask: "should it be reported as a bug ?"

And my answer is: yes, because I think it is. Why? Because the error reported by the syntax check is:

Code: Select all

Line 17: And_That() is not a function, array, list, map or macro.
That's not a syntax error at all. The syntax of line 17 is perfectly valid for PureBasic.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 11:50 am
by NicknameFJ
Dude wrote:
NicknameFJ wrote:I never said / meant that it is a bug.
But you did ask: "should it be reported as a bug ?"
No I didn't.

Blue asked it in his first post, not me.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 11:52 am
by Dude
NicknameFJ wrote:Blue asked it in his first post, not me.
Now I need some sleep. Sorry about that! :lol:

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 12:04 pm
by NicknameFJ
Dude wrote:
NicknameFJ wrote:Blue asked it in his first post, not me.
Now I need some sleep. Sorry about that! :lol:

No problem.

Take a sleep. :mrgreen:

NicknameFJ

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Sun Mar 29, 2015 12:17 pm
by luis
The reality is "Syntax check" evidently does not do a syntax check.
Syntax can be checked not only for a whole program but for snippets too, and clearly in a snippet or fragment you can reference something defined elsewhere and not visible in the snippet itself.
A syntax check, since the syntax is valid, should be able to successfully check the code by the OP.
In PB the menu option seems more a "Compile to NULL" than a syntax check. It tries to "compile" the program without going forward enough to build the EXE.
And since "Create executable" exhibits the same behavior with the code posted here, raising an error because it's not compilable in release mode, "Syntax check" is probably intended to work the same way.
This is not what I would expect when I select an option with this name but should be sufficient to document what it actually does: a validation of the the whole program to verify it is compilable without errors in release mode.

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Mon Mar 30, 2015 4:37 am
by Blue
@Luis :
Thank you for a well developed train of thought. And i fully share your perplexity regarding the strangeness of the example code ( :shock: ), but indeed, as you point out, one would expect a syntax check to actually check the syntax :D , not my PB IQ !

You synthetized nicely what actually happens in
Luis wrote: a validation of the whole program to verify it is compilable without errors in release mode.
I think that should appear in the help file, in the appropriate section.

clarification needed: what does OP stand for in
Luis wrote:to successfully check the code by the OP
?

At any rate, as you wrote in your first reply, "Who knows ?" And, therefore, with the expected behaviour of this functionality not actually spelled out anywhere, we can only conclude that, technically, this is not a bug.
Which is not the same, mind you, as saying that it makes perfect sense...

Re: Syntax check not aware of compiler conditionals (bug ??)

Posted: Mon Mar 30, 2015 11:09 am
by luis
Blue wrote: clarification needed: what does OP stand for in ...
Sorry, it's one of those internet acronyms: original poster (the person) or original post (the text) depending on the context.
Blue wrote: with the expected behaviour of this functionality not actually spelled out anywhere, we can only conclude that, technically, this is not a bug.
Yes, it happens continually with PB especially with the language itself. Most things are learned "by example" in the forum or inferred by practical experimentation since there is no real definition of the language.
Most of what can be done or not you don't know just by reading the help, you discover it by trying and asking yourself "does it make sense ?"
From there the questions in the forum and the more or less sensible bug reports.
Then some deductions get official confirmation or just acquire the unofficial status of fact and are referred in conversations like virtual addendum of the documentation.
That's one reason why the forum is vital for PB, it is part of the product. Without it would be worth a lot less.
That's how PB work, up to a point it's understandable.