Skip to content
Tcl Source Code History Of Ticket 1584674fff
Login

History Of Ticket 1584674fff

Artifacts Associated With Ticket 1584674fff

  1. Ticket change [d2ba4d232d] (rid 113581) by pcmacdon on 2006-10-25 19:09:51:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I was trying out 8.5a5 thinking that it's new compiled
      switch feature would improve Tcl's detection of syntax
      errors in switch arms, but instead found not only 
      is it unchanged, but that the basic error detection of
      "if" is now gone.  For example the following script
      causes 8.3 and 8.4 to barf, but is perfectly legal
      in 8.5:
      
        proc bar var {
          if {$var == "acorn"} {
            set a b c
          }
        }
        bar a
      
      Ditto for 
      
        proc bar var {
          if {$var == "acorn"} {
            set a [b c
          }
        }
      
      
      The "no errors til you execute it" policy means
      you need nearly perfect code coverage testing
      to use Tcl with any confidence.
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "pcmacdon"
    10. subsystem initialized to: "None"
    11. title initialized to: "where has the syntax error detection gone"
    12. type initialized to: "Bug"
  2. Ticket change [0adc5a0550] (rid 113893) by dkf on 2006-10-26 04:27:43:

    1. assignee changed to: "msofer"
    2. foundin changed to: "obsolete: 8.5a5"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      Because you can do some horrible hacks like this now:
      
        rename if if_
        proc if args {
           foreach a $args {puts $a}
        }
        bar var
        rename if {}
        rename if_ if
      
      OK, that's rather odd code, but it's legal. If you want
      static syntax checking, use a third-party tool like Nagelfar.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. priority changed to: "3 Low"
    7. subsystem changed to: "47. Bytecode Compiler"
    8. username: "dkf"
  3. Ticket change [48dda5dc6b] (rid 99964) by pcmacdon on 2006-10-26 07:00:54:

    1. icomment:
      Logged In: YES 
      user_id=190660
      
      Wonderful, Tcl will have even less checking.
      
      Any idea how hard it would be to optionally 
      disable this lazy compile?
      
      
    2. login: "pcmacdon"
    3. mimetype: "text/plain"
    4. username: "pcmacdon"
  4. Ticket change [b3254ef85c] (rid 98474) by pcmacdon on 2006-10-27 06:12:32:

    1. icomment:
      Logged In: YES 
      user_id=190660
      Originator: YES
      
      I understand a little better now whats going on.
      Compilation is not being deferred but rather errors are
      being ignored.
      
      The main change seems to be in TclCompileScript() which
      no longer provides a return code.
      
      I looked at the two simple test cases in 8.5a5 and in both
      cases it is TclCompileScript() that is ignoring the compile
      errors.
      
      
      (Case 1):
          # set a [badcall c
      
      Line 1006:
          if (Tcl_ParseCommand(interp, p, bytesLeft, 0, &parse) !=
      TCL_OK)
      
      Just compiles a returnCmd which the invocation chain
      ignores. This is a syntax error which I think should be
      reported.
      
      
      (Case 2):
        # set a b c
      
      Line 1183:   
         code = (cmdPtr->compileProc)(interp, &parse, envPtr);
         ...
         /* Restore numCommands and codeNext to their ... */
      
      Not sure what's the goal here.  If you just wanted to
      redefine 'if' you can do that in 8.4 so long as 'proc if' is
      defined before this code is compiled.
      
      Oh, and Donal I think your code example is invalid.
      Did you mean:
      
        if bar var
      
      Also, static code checkers aren't really an option.  On
      the second module I tried them on, frink core dumped and
      nagelfar generated an error for every 10th line of code.
      
      
      
    2. login: "pcmacdon"
    3. mimetype: "text/plain"
    4. username: "pcmacdon"
  5. Ticket change [438f6e56a0] (rid 116575) by pcmacdon on 2006-10-27 07:32:39:

    1. icomment:
      Logged In: YES 
      user_id=190660
      
       
      Right.  But we could already do that as long as 'proc if' is define before compiling bar.  eg. the following works
      in 8.3:
      
        proc bar var {
          if {$var == "acorn"} {
            set a b c
          }
        }
        catch {bar acorn}
        rename if if_
        proc if args {
           foreach a $args {puts $a}
        }
      
        bar var
        rename if {}
        rename if_ if
      
      I wonder if you didn't mean the following (which
      also works in 8.3)?
      
        proc bar var {
          if {$var == "acorn"} {
            set a b c
          }
        }
        catch {bar acorn}
        rename set set_
        proc set args {
           foreach a $args {puts $a}
        }
      
        bar acorn
        rename set {}
        rename set_ set
      
      
      
      
    2. login: "pcmacdon"
    3. mimetype: "text/plain"
    4. username: "pcmacdon"
  6. Ticket change [aa31c2e8cf] (rid 99283) by dgp on 2006-10-28 13:20:23:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      >    # set a [badcall c
      
      > Just compiles a returnCmd which the invocation chain
      > ignores. 
      
      No, it compiles to bytecode that reports the
      syntax error at runtime.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [92bddfcc60] (rid 120826) by pcmacdon on 2006-10-29 05:37:05:

    1. icomment:
      Logged In: YES 
      user_id=190660
      
      Hence: no errors till you execute it.
      
      
    2. login: "pcmacdon"
    3. mimetype: "text/plain"
    4. username: "pcmacdon"
  8. Ticket change [646cf9084a] (rid 92768) by msofer on 2008-01-12 20:46:25:

    1. closedate changed to: "2008-01-12T13:46:25"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      Originator: NO
      
      This is per design. Tcl's has string interpretation semantics, the bytecompiler has to respect that. Tcl8.5 has fixed a number of bugs in that area.
      
      If we checked for syntax errors you couldn't run the following "perfectly valid" code. Tcl8.4 will return an error, which is a bug.
      
      proc foo bar {
          if {$bar == 0} {
              set a [badcall c
          } else {
              set a $bar
          }
      }
      foo 1 ;# returns 1
      proc if args {return $args}
      foo 0
      
      Not arguing that you would *want* to run code like that, only that a string interpretation language will run it.
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. username: "msofer"