Artifacts Associated With Ticket 1584674
Ticket change [d2ba4d232d] (rid 113581) by pcmacdon on 2006-10-25 19:09:51:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "pcmacdon"
- subsystem initialized to: "None"
- title initialized to: "where has the syntax error detection gone"
- type initialized to: "Bug"
Ticket change [0adc5a0550] (rid 113893) by dkf on 2006-10-26 04:27:43:
- assignee changed to: "msofer"
- foundin changed to: "obsolete: 8.5a5"
- 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. - login: "dkf"
- mimetype: "text/plain"
- priority changed to: "3 Low"
- subsystem changed to: "47. Bytecode Compiler"
- username: "dkf"
Ticket change [48dda5dc6b] (rid 99964) by pcmacdon on 2006-10-26 07:00:54:
- 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?
- login: "pcmacdon"
- mimetype: "text/plain"
- username: "pcmacdon"
- icomment:
Ticket change [b3254ef85c] (rid 98474) by pcmacdon on 2006-10-27 06:12:32:
- 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. - login: "pcmacdon"
- mimetype: "text/plain"
- username: "pcmacdon"
- icomment:
Ticket change [438f6e56a0] (rid 116575) by pcmacdon on 2006-10-27 07:32:39:
- 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 - login: "pcmacdon"
- mimetype: "text/plain"
- username: "pcmacdon"
- icomment:
Ticket change [aa31c2e8cf] (rid 99283) by dgp on 2006-10-28 13:20:23:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [92bddfcc60] (rid 120826) by pcmacdon on 2006-10-29 05:37:05:
- icomment:
Logged In: YES user_id=190660 Hence: no errors till you execute it.
- login: "pcmacdon"
- mimetype: "text/plain"
- username: "pcmacdon"
- icomment:
Ticket change [646cf9084a] (rid 92768) by msofer on 2008-01-12 20:46:25:
- closedate changed to: "2008-01-12T13:46:25"
- closer changed to: "msofer"
- 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. - login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "msofer"