augeas icon indicating copy to clipboard operation
augeas copied to clipboard

Rejects this perfectly valid lens: (value "v" . del /a/ "a")|(value "w" . del /b/ "b")

Open safinaskar opened this issue 4 years ago • 2 comments

Consider this file a.aug:

module A =
let lns = (value "v" . del /a/ "a")|(value "w" . del /b/ "b")

I think this lens is perfectly valid. It is bijective. But augparse rejects it with the message:

Syntax error in lens definition
/tmp/a.aug:2.0-.61:Failed to compile lns
/tmp/a.aug:2.10-.61:exception: overlapping lenses in tree union.put
    Example matched by both: 
    First lens: /tmp/a.aug:2.10-.34:
    Second lens: /tmp/a.aug:2.31-.60:

Also, please note that line Example matched by both: doesn't show any example, this is strange. I use version of augeas included in debian sid, i. e. 1.12.0. My system is debian sid amd64

safinaskar avatar Jul 29 '20 08:07 safinaskar

I don't know why exactly, but this type of constructs require two separate subtrees:

module A =                                                                          
let lns = [value "v" . del /a/ "a" ]| [value "w" . del /b/ "b"]    

raphink avatar Jul 29 '20 11:07 raphink

I am not sure what exactly is going wrong there, but the put test below outputs a, not b, when I run it through augparse --notypecheck so something's up:

module A =
let v = (value "v" . del /a/ "a")|(value "w" . del /b/ "b")
let lns = [label "x" . v]

test lns get "a" = ?
test lns get "b" = ?
test lns put "a" after set "/x" "b" = ?

lutter avatar Sep 03 '20 01:09 lutter