Tcl Source Code

View Ticket
Login
Ticket UUID: ba921a8d98e02a96617835bfdc3437e2a4db9e1b
Title: concatenating binary array with empty string yields the empty string
Type: Bug Created on: 2018-07-22 20:35:20
Submitter: pooryorick Assigned to: dgp
Subsystem: 10. Objects Severity: Important
Priority: 5 Medium Last modified: 2018-07-26 16:18:17
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2018-07-26 16:18:17
Version: core-8-branch
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:
pooryorick added on 2018-07-22 20:46:33:

Fixed in [f274e1f1baf02516].


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
%

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-26 16:18:17:
Test and fix committed.