Tcl Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: ba921a8d98e02a96617835bfdc3437e2a4db9e1b
Title: concatenating binary array with empty string yields the empty string
Type: Bug Version: core-8-branch
Submitter: pooryorick Created on: 2018-07-22 20:35:20
Subsystem: 10. Objects Assigned To: dgp
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2018-07-26 16:18:17
Resolution: Fixed Closed By: dgp
    Closed on: 2018-07-26 16:18:17
Description:

The result of the following script is the empty string:

proc main {} {
    set data [binary format a* hello]
    puts $data
    puts $data[set data {}]
}

main

User Comments: dgp added on 2018-07-26 16:18:17:
Test and fix committed.

anonymous added on 2018-07-25 21:34:47:

Just for the records, a variant of the original snippet without [puts]:

proc main {} {
    set data [binary format a* hello]
    return [expr {$data}][set data {}]
}
main


dgp added on 2018-07-25 19:27:40:
Fix isn't right yet:

% proc demo {} {
    set data [binary format a* hello]
    return [encoding convertto $data]$data
}
% demo
hellolr
%

pooryorick added on 2018-07-22 20:46:33:

Fixed in [f274e1f1baf02516].