Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e21af532337e6f96305188c8fe1ccaac94b99903
Ticket: 1e95cbaf89ad0e0d48aa374d7ad0515ea2c2b862
Evaluating something starting with a # fails to treat it as a comment
User & Date: Grumpy Coder on 2014-04-04 04:30:01
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    So I decided to stop living in the past and upgraded from Tcl 8.4 to 8.6. And got bitten by something that used to work just fine:
    
    First, the expected behavior:
    
    tclsh8.6
    % set tcl_patchLevel
    8.6.1
    % set comment "#fubar snafu"
    #fubar snafu
    % lindex $comment 0
    #fubar
    % eval $comment
    % 
    
    Now the same thing with a list. Note that in Tcl 8.4, the commands below worked identically to the above.  Not so in 8.6:
    
    % set comment [list #fubar snafu]
    {#fubar} snafu
    % lindex $comment 0
    #fubar
    % eval $comment
    invalid command name "#fubar"
    
    Looks like a bug in parsing. The first word of the list is unquestionably this:
    
    #fubar
    
    This is clear from the result of 'lindex' and from the language rules (http://www.tcl.tk/man/tcl8.6/TclCmd/Tcl.htm):
    
    "If the first character of a word is an open brace (“{”) and rule [5] does not apply ... The word will consist of exactly the characters between the outer braces, not including the braces themselves"
    
    and
    
    "If a hash character (“#”) appears at a point where Tcl is expecting the first character of the first word of a command, then the hash character and the characters that follow it, up through the next newline, are treated as a comment and ignored. The comment character only has significance when it appears at the beginning of a command."
    
    Well, I do have # in first character of the first word of the command. Why is Tcl8.6 not treating it as a comment???
    
    While I don't have a newline in here, newlines are separators and I have one command to evaluate, so separator presence is moot. But let's add it:
    
    % eval "$comment\n"
    invalid command name "#fubar"
    
    Still not good.
    
    Looks like a clear bug to me.
    
  5. foundin changed to: "8.6.1"
  6. is_private changed to: "0"
  7. login: "Grumpy Coder"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "51e6fca6c11afbb182a55eb093d92ab68ef5a61b"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "Grumpy Coder"
  14. subsystem changed to: "45. Parsing and Eval"
  15. title changed to:
    Evaluating something starting with a # fails to treat it as a comment
    
  16. type changed to: "Bug"