this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pkg/path: fix path issue

Use proper accessor for Conjuncts so that
all necessary conjuncts are visited.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I501335b9950556979f67c91df6f827991c12378a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202657
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+11 -275
+3 -3
internal/core/adt/composite.go
··· 635 635 636 636 // VisitLeafConjuncts visits all conjuncts that are leafs of the ConjunctGroup tree. 637 637 func (v *Vertex) VisitLeafConjuncts(f func(Conjunct) bool) { 638 - visitConjuncts(v.Conjuncts, f) 638 + VisitConjuncts(v.Conjuncts, f) 639 639 } 640 640 641 - func visitConjuncts(a []Conjunct, f func(Conjunct) bool) bool { 641 + func VisitConjuncts(a []Conjunct, f func(Conjunct) bool) bool { 642 642 for _, c := range a { 643 643 switch x := c.x.(type) { 644 644 case *ConjunctGroup: 645 - if !visitConjuncts(*x, f) { 645 + if !VisitConjuncts(*x, f) { 646 646 return false 647 647 } 648 648 default:
+8 -6
internal/core/export/value.go
··· 245 245 return ast.NewBool(n.B) 246 246 } 247 247 248 - func extractBasic(a []adt.Conjunct) *ast.BasicLit { 249 - for _, v := range a { 250 - if b, ok := v.Source().(*ast.BasicLit); ok { 251 - return &ast.BasicLit{Kind: b.Kind, Value: b.Value} 248 + func extractBasic(a []adt.Conjunct) (lit *ast.BasicLit) { 249 + adt.VisitConjuncts(a, func(c adt.Conjunct) bool { 250 + if b, ok := c.Source().(*ast.BasicLit); ok { 251 + lit = &ast.BasicLit{Kind: b.Kind, Value: b.Value} 252 + return false 252 253 } 253 - } 254 - return nil 254 + return true 255 + }) 256 + return lit 255 257 } 256 258 257 259 func (e *exporter) num(n *adt.Num, orig []adt.Conjunct) *ast.BasicLit {
-266
pkg/path/testdata/join.txtar
··· 57 57 {arg: [#"C:a"#, #"b"#]}, 58 58 {arg: [#"\\host\share"#, #"foo"#]}, 59 59 ] 60 - -- out/path-v3 -- 61 - joinSingle: "a/b" 62 - Join: { 63 - unix: [{ 64 - arg: ["a", "b"] 65 - out: "a/b" 66 - }, { 67 - arg: ["a/b", "c/d"] 68 - out: "a/b/c/d" 69 - }, { 70 - arg: ["/"] 71 - out: "/" 72 - }, { 73 - arg: ["a"] 74 - out: "a" 75 - }, { 76 - arg: ["a", "b"] 77 - out: "a/b" 78 - }, { 79 - arg: ["a", ""] 80 - out: "a" 81 - }, { 82 - arg: ["", "b"] 83 - out: "b" 84 - }, { 85 - arg: ["/", "a"] 86 - out: "/a" 87 - }, { 88 - arg: ["/", "a/b"] 89 - out: "/a/b" 90 - }, { 91 - arg: ["/", ""] 92 - out: "/" 93 - }, { 94 - arg: ["//", "a"] 95 - out: "/a" 96 - }, { 97 - arg: ["directory", "file"] 98 - out: "directory/file" 99 - }, { 100 - arg: ["C:\\Windows\\", "System32"] 101 - out: "C:\\Windows\\/System32" 102 - }, { 103 - arg: ["C:\\Windows\\", ""] 104 - out: "C:\\Windows\\" 105 - }, { 106 - arg: ["C:\\", "Windows"] 107 - out: "C:\\/Windows" 108 - }, { 109 - arg: ["C:", "a\\b"] 110 - out: "C:/a\\b" 111 - }, { 112 - arg: ["C:", "a", "b"] 113 - out: "C:/a/b" 114 - }, { 115 - arg: ["C:", "", "", "b"] 116 - out: "C:/b" 117 - }, { 118 - arg: ["C:", ""] 119 - out: "C:" 120 - }, { 121 - arg: ["C:", "", ""] 122 - out: "C:" 123 - }, { 124 - arg: ["C:.", "a"] 125 - out: "C:./a" 126 - }, { 127 - arg: ["C:a", "b"] 128 - out: "C:a/b" 129 - }, { 130 - arg: ["\\\\host\\share", "foo"] 131 - out: "\\\\host\\share/foo" 132 - }] 133 - windows: [{ 134 - arg: ["a", "b"] 135 - out: "a\\b" 136 - }, { 137 - arg: ["a/b", "c/d"] 138 - out: "a\\b\\c\\d" 139 - }, { 140 - arg: ["/"] 141 - out: "\\" 142 - }, { 143 - arg: ["a"] 144 - out: "a" 145 - }, { 146 - arg: ["a", "b"] 147 - out: "a\\b" 148 - }, { 149 - arg: ["a", ""] 150 - out: "a" 151 - }, { 152 - arg: ["", "b"] 153 - out: "b" 154 - }, { 155 - arg: ["/", "a"] 156 - out: "\\a" 157 - }, { 158 - arg: ["/", "a/b"] 159 - out: "\\a\\b" 160 - }, { 161 - arg: ["/", ""] 162 - out: "\\" 163 - }, { 164 - arg: ["//", "a"] 165 - out: "\\a" 166 - }, { 167 - arg: ["directory", "file"] 168 - out: "directory\\file" 169 - }, { 170 - arg: ["C:\\Windows\\", "System32"] 171 - out: "C:\\Windows\\System32" 172 - }, { 173 - arg: ["C:\\Windows\\", ""] 174 - out: "C:\\Windows" 175 - }, { 176 - arg: ["C:\\", "Windows"] 177 - out: "C:\\Windows" 178 - }, { 179 - arg: ["C:", "a\\b"] 180 - out: "C:a\\b" 181 - }, { 182 - arg: ["C:", "a", "b"] 183 - out: "C:a\\b" 184 - }, { 185 - arg: ["C:", "", "", "b"] 186 - out: "C:b" 187 - }, { 188 - arg: ["C:", ""] 189 - out: "C:." 190 - }, { 191 - arg: ["C:", "", ""] 192 - out: "C:." 193 - }, { 194 - arg: ["C:.", "a"] 195 - out: "C:a" 196 - }, { 197 - arg: ["C:a", "b"] 198 - out: "C:a\\b" 199 - }, { 200 - arg: ["\\\\host\\share", "foo"] 201 - out: "\\\\host\\share\\foo" 202 - }] 203 - } 204 - -- diff/-out/path-v3<==>+out/path -- 205 - diff old new 206 - --- old 207 - +++ new 208 - @@ -37,37 +37,37 @@ 209 - arg: ["directory", "file"] 210 - out: "directory/file" 211 - }, { 212 - - arg: [#"C:\Windows\"#, #"System32"#] 213 - + arg: ["C:\\Windows\\", "System32"] 214 - out: "C:\\Windows\\/System32" 215 - }, { 216 - - arg: [#"C:\Windows\"#, #""#] 217 - + arg: ["C:\\Windows\\", ""] 218 - out: "C:\\Windows\\" 219 - }, { 220 - - arg: [#"C:\"#, #"Windows"#] 221 - + arg: ["C:\\", "Windows"] 222 - out: "C:\\/Windows" 223 - }, { 224 - - arg: [#"C:"#, #"a\b"#] 225 - + arg: ["C:", "a\\b"] 226 - out: "C:/a\\b" 227 - }, { 228 - - arg: [#"C:"#, #"a"#, #"b"#] 229 - + arg: ["C:", "a", "b"] 230 - out: "C:/a/b" 231 - }, { 232 - - arg: [#"C:"#, #""#, #""#, #"b"#] 233 - + arg: ["C:", "", "", "b"] 234 - out: "C:/b" 235 - }, { 236 - - arg: [#"C:"#, #""#] 237 - - out: "C:" 238 - - }, { 239 - - arg: [#"C:"#, #""#, #""#] 240 - - out: "C:" 241 - - }, { 242 - - arg: [#"C:."#, #"a"#] 243 - + arg: ["C:", ""] 244 - + out: "C:" 245 - + }, { 246 - + arg: ["C:", "", ""] 247 - + out: "C:" 248 - + }, { 249 - + arg: ["C:.", "a"] 250 - out: "C:./a" 251 - }, { 252 - - arg: [#"C:a"#, #"b"#] 253 - + arg: ["C:a", "b"] 254 - out: "C:a/b" 255 - }, { 256 - - arg: [#"\\host\share"#, #"foo"#] 257 - + arg: ["\\\\host\\share", "foo"] 258 - out: "\\\\host\\share/foo" 259 - }] 260 - windows: [{ 261 - @@ -107,37 +107,37 @@ 262 - arg: ["directory", "file"] 263 - out: "directory\\file" 264 - }, { 265 - - arg: [#"C:\Windows\"#, #"System32"#] 266 - + arg: ["C:\\Windows\\", "System32"] 267 - out: "C:\\Windows\\System32" 268 - }, { 269 - - arg: [#"C:\Windows\"#, #""#] 270 - - out: "C:\\Windows" 271 - - }, { 272 - - arg: [#"C:\"#, #"Windows"#] 273 - - out: "C:\\Windows" 274 - - }, { 275 - - arg: [#"C:"#, #"a\b"#] 276 - - out: "C:a\\b" 277 - - }, { 278 - - arg: [#"C:"#, #"a"#, #"b"#] 279 - - out: "C:a\\b" 280 - - }, { 281 - - arg: [#"C:"#, #""#, #""#, #"b"#] 282 - + arg: ["C:\\Windows\\", ""] 283 - + out: "C:\\Windows" 284 - + }, { 285 - + arg: ["C:\\", "Windows"] 286 - + out: "C:\\Windows" 287 - + }, { 288 - + arg: ["C:", "a\\b"] 289 - + out: "C:a\\b" 290 - + }, { 291 - + arg: ["C:", "a", "b"] 292 - + out: "C:a\\b" 293 - + }, { 294 - + arg: ["C:", "", "", "b"] 295 - out: "C:b" 296 - }, { 297 - - arg: [#"C:"#, #""#] 298 - - out: "C:." 299 - - }, { 300 - - arg: [#"C:"#, #""#, #""#] 301 - - out: "C:." 302 - - }, { 303 - - arg: [#"C:."#, #"a"#] 304 - + arg: ["C:", ""] 305 - + out: "C:." 306 - + }, { 307 - + arg: ["C:", "", ""] 308 - + out: "C:." 309 - + }, { 310 - + arg: ["C:.", "a"] 311 - out: "C:a" 312 - }, { 313 - - arg: [#"C:a"#, #"b"#] 314 - - out: "C:a\\b" 315 - - }, { 316 - - arg: [#"\\host\share"#, #"foo"#] 317 - + arg: ["C:a", "b"] 318 - + out: "C:a\\b" 319 - + }, { 320 - + arg: ["\\\\host\\share", "foo"] 321 - out: "\\\\host\\share\\foo" 322 - }] 323 - } 324 - -- diff/todo/p2 -- 325 - Differing string representation of semantically identical strings. 326 60 -- out/path -- 327 61 joinSingle: "a/b" 328 62 Join: {