...

Text file src/cuelang.org/go/cue/testdata/export/issue2244.txtar

Documentation: cuelang.org/go/cue/testdata/export

     1-- in.cue --
     2package x
     3
     4import (
     5	"strings"
     6)
     7
     8_#matchPattern: {
     9	#pattern: string
    10	[
    11		// can't remove this builtin call
    12		if strings.HasSuffix(#pattern, "*") {
    13
    14			// this let is required _within_ the if block
    15			// i.e. it can't be "inlined" with the if that
    16			// currently contains it
    17			let prefix = strings.TrimSuffix(#pattern, "*")
    18
    19			prefix
    20		},
    21		"'\(#pattern)'",
    22	][0]
    23}
    24
    25_#isReleaseTag: _#matchPattern & {#pattern: "refs/tags/v*", _}
    26
    27#step: {
    28	if: number | string
    29}
    30
    31m: #step & {
    32	if: _#isReleaseTag
    33}
    34-- out/eval/stats --
    35Leaks:  16
    36Freed:  17
    37Reused: 13
    38Allocs: 20
    39Retain: 30
    40
    41Unifications: 24
    42Conjuncts:    58
    43Disjuncts:    40
    44-- out/eval --
    45(struct){
    46  _#matchPattern(:x): (_|_){
    47    // [incomplete] _#matchPattern: error in call to strings.HasSuffix: non-concrete value string:
    48    //     ./in.cue:11:6
    49    //     ./in.cue:8:12
    50    #pattern: (string){ string }
    51  }
    52  _#isReleaseTag(:x): (string){
    53    "refs/tags/v"
    54    #pattern: (string){ "refs/tags/v*" }
    55    let prefix#1 = (string){ "refs/tags/v" }
    56  }
    57  #step: (#struct){
    58    if: ((string|number)){ |((number){ number }, (string){ string }) }
    59  }
    60  m: (#struct){
    61    if: (string){
    62      "refs/tags/v"
    63      #pattern: (string){ "refs/tags/v*" }
    64      let prefix#1 = (string){ "refs/tags/v" }
    65    }
    66  }
    67}
    68-- out/compile --
    69--- in.cue
    70{
    71  _#matchPattern: {
    72    #pattern: string
    73    [
    74      if 〈import;strings〉.HasSuffix(〈1;#pattern〉, "*") {
    75        let prefix#1 = 〈import;strings〉.TrimSuffix(〈2;#pattern〉, "*")
    76        〈0;let prefix#1〉
    77      },
    78      "'\(〈1;#pattern〉)'",
    79    ][0]
    80  }
    81  _#isReleaseTag: (〈0;_#matchPattern〉 & {
    82    #pattern: "refs/tags/v*"
    83    _
    84  })
    85  #step: {
    86    if: (number|string)
    87  }
    88  m: (〈0;#step〉 & {
    89    if: 〈1;_#isReleaseTag〉
    90  })
    91}

View as plain text