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

Working on new editor enhancements?
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

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

Post 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 ?

 
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
NicknameFJ
User
User
Posts: 90
Joined: Tue Mar 17, 2009 6:36 pm
Location: Germany

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

Post by NicknameFJ »

How should syntax check know the constants setting which are made by the IDE when starting the compiling? No bug.
PS: Sorry for my weird english, but english is not my native language.



Image
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

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

Post by Tenaja »

What this clearly demonstrates (in my view) is the debugger is NOT enabled during Syntax Check.
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

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

Post 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
The Stone Age did not end due to a shortage of stones !
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

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

Post 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.
User avatar
NicknameFJ
User
User
Posts: 90
Joined: Tue Mar 17, 2009 6:36 pm
Location: Germany

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

Post 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?
PS: Sorry for my weird english, but english is not my native language.



Image
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

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

Post 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.
User avatar
NicknameFJ
User
User
Posts: 90
Joined: Tue Mar 17, 2009 6:36 pm
Location: Germany

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

Post 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.
PS: Sorry for my weird english, but english is not my native language.



Image
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

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

Post by Dude »

NicknameFJ wrote:Blue asked it in his first post, not me.
Now I need some sleep. Sorry about that! :lol:
User avatar
NicknameFJ
User
User
Posts: 90
Joined: Tue Mar 17, 2009 6:36 pm
Location: Germany

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

Post 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
PS: Sorry for my weird english, but english is not my native language.



Image
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

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

Post 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...
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply