bugmake - Bugs: bug #7310, comments are not ignored in...

 
 

bug #7310: comments are not ignored in $(call) /$(eval)

Submitter:  Boris Kolpackov <bosk>
Submitted:  Sun 18 Jan 2004 05:36:40 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.0 Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Jan 2004 05:50:53 AM UTC, comment #1: 

Your evaluation is not quite correct.  Comments ARE ignored.  However, in the example above the warning function is evaluated before the comment comes into effect.

Values inside a define/endef do not undergo treatment to remove comments: the lines inside that block are assigned verbatim to the variable.

Next, the call function is invoked on variable "foo", with an argument of "baz".  That is completely expanded and the results of that expansion are passed to the eval function to be evaluated.

When the call function evaluates the foo variable as a function, it is not examined for comment characters first, because normally these are stripped off when the value is read in.  Because of that, the warning function is evaluated at that time, and the warning is printed.  The $(eval ...) reference here is a red herring: you would get the same output if you'd invoked just $(call ...) by itself.  By the time the eval function gets the value the warning has been printed and replaced with an empty string, so eval just sees the string "#", which it properly ignores as a comment.

I don't see any way to change this behavior; if call were changed to check for comments then first, that would not be a backward-compatible change, and second we'd have to change all the other functions in that way as well, to be consistent.  I'm not even sure it's really incorrect behavior, per se, although I grant you it's surprising at first.  But, when using call and eval it's critically important to be very familiar with evaluation of variables, where it happens, and how it works.

Paul D. Smith <psmith>
Group administrator
Sun 18 Jan 2004 05:36:40 AM UTC, original submission:  

$ cat > comment

define foo
#$(warning $(1))
endef

define bar
$(eval $(call foo,baz))
endef

$(call bar)

$ make -f comment
comment:8: baz
make: * No targets.  Stop.

Boris Kolpackov <bosk>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-01-19 psmith StatusNone Not A Bug
    Assigned toNone psmith
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code