[augeas-devel] [PATCH] Proper typecheck for lens unions

David Lutterkort dlutter at redhat.com
Mon May 12 18:22:22 UTC 2008


On Mon, 2008-05-12 at 10:24 -0700, David Lutterkort wrote:
> I did that without thinking much - yes, you are right, there shouldn't
> be a need for the atype check, though I need to fill in a couple of
> FIXME's in put.c when I check whether a skeleton matches the skeleton
> type of a lens.

After playing with unions without checking for disjointness of the
atype, I managed to get this:

        let del_str (s:string) = del s s
        
        let lns = [ key /a/ . store /b/ . del_str " (l)" ] 
                | [ key /a/ . store /c/ . del_str " (r)" ]
        
        test lns put "ac (r)" after set "a" "b" = "ab (r)"

which is not at all what one would expect, this should yield "ab (l)",
i.e. switch from using the second branch in the union to the first. 

Since lns.get "ab (r)" isn't even defined, this is pretty bad. The
reason for the failure is the simplistic way in which I match trees to
lenses: simply by looking at the label of the node.

Until I figure out how to fix this properly, I'll be more comfortable
with having the overzealous lens union typecheck in place.

David





More information about the augeas-devel mailing list