It is currently Sat Jan 23, 2021 8:42 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sat Mar 28, 2015 3:34 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
With the following simpleton of program :
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sat Mar 28, 2015 4:36 pm 
Offline
User
User
User avatar

Joined: Tue Mar 17, 2009 6:36 pm
Posts: 87
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sat Mar 28, 2015 5:37 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1719
What this clearly demonstrates (in my view) is the debugger is NOT enabled during Syntax Check.


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sat Mar 28, 2015 7:25 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 587
Location: Canada
To do something like this you have to tihs

Code:
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 !


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sat Mar 28, 2015 8:13 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3698
Location: Italy
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.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 1:19 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1907
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 10:36 am 
Offline
User
User
User avatar

Joined: Tue Mar 17, 2009 6:36 pm
Posts: 87
Location: Germany
@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


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 11:44 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1907
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:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 11:50 am 
Offline
User
User
User avatar

Joined: Tue Mar 17, 2009 6:36 pm
Posts: 87
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 11:52 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1907
NicknameFJ wrote:
Blue asked it in his first post, not me.

Now I need some sleep. Sorry about that! :lol:


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 12:04 pm 
Offline
User
User
User avatar

Joined: Tue Mar 17, 2009 6:36 pm
Posts: 87
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Sun Mar 29, 2015 12:17 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3698
Location: Italy
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.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Mon Mar 30, 2015 4:37 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
@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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Syntax check not aware of compiler conditionals (bug ??)
PostPosted: Mon Mar 30, 2015 11:09 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3698
Location: Italy
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.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye