Tcl Library Source Code

View Ticket
Login
Ticket UUID: 5edaf187fa3e13d9327cb0ff9c168be12174c2e0
Title: struct::graph is inconsistent about the support of nodes starting with a dash
Type: Bug Version: struct::graph 2.4
Submitter: anonymous Created on: 2018-12-27 13:37:28
Subsystem: struct :: graph Assigned To: aku
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2019-04-13 03:38:05
Resolution: Fixed Closed By: aku
    Closed on: 2019-04-13 03:38:05
Description:
graph node insert -foo ;# works
g walk -foo -command {apply {args {puts stderr [info level 0]}}} ;# results in

apply {args {puts stderr [info level 0]}} enter ::g -foo
bad restriction "-foo": must be -adj, -embedding, -filter, -in, -inner, -key, -out, or -value
while evaluating {g walk -foo -command {apply {args {puts stderr [info level 0]}}}}

Note how apply is invoked, i.e. [walk] is not directly affected, but one of the internals that it calls.

I know that fixing this will be quite some work, but it is an actual restriction: e.g. the package does not work for negative numbers as node names
User Comments: aku added on 2019-04-13 03:38:05:

Fixed with commit [bb9e30207b].

Version bump 2.4.2.


aku added on 2019-04-11 21:14:32:
Error is thrown by `::struct::graph::CheckE`, an internal argument validator.

Likely from the use within the `nodes` method.

4 calls of _nodes in _walk.

As `_nodes $dir $node`, with $dir in -in, -out.

The processing of -in, -out, etc. is not properly managing the node names.
It should pull them directly when processing the filter instead of looping.
Except, as it is documented we are allowed to say

    -in node1 node2 ... -value foo

And now a node name like -bar is difficult to distinguish from an invalid option.

Right now we default to treat it as invalid filter option.

Not sure yet what trouble we may get into if we default the other way, i.e. treat as node name

Actually we can influence that by the option we have seen, i.e. change treatment only after one of the filter options taking nodes and change back when reaching one of the other options.

That might be our best bet for a heuristics.