Skip to content

Commit

Permalink
pkg/path: add missing param declaration
Browse files Browse the repository at this point in the history
The standard library function path.Match requires 3 parameters, but only
2 are currently declared. This causes valid usage of the function to
fail with the following error:

    too many arguments in call to path.Match (have 3, want 2):

To fix this, the missing parameter declaration is added.

Fixes #3203.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: I6e645293f8e589ad1834e3c33ff7bffc2abb5aed
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195888
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
NoamTD authored and mvdan committed Jun 6, 2024
1 parent 889da91 commit e09cb31
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/path/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ var p = &pkg.Package{
}, {
Name: "Match",
Params: []pkg.Param{
{Kind: adt.StringKind},
{Kind: adt.StringKind},
{Kind: adt.StringKind, Value: unixDefault},
},
Expand Down
55 changes: 55 additions & 0 deletions pkg/path/testdata/os.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ Clean: [_]: {
#"c:\abc\def\..\.."#: _
}

Match: [OS=#AnyOS]: [Pattern=string]: [Name=string]: path.Match(Pattern, Name, OS)
Match: default: [Pattern=string]: [Name=string]: path.Match(Pattern, Name)
Match: default: Match.unix
Match: [_]: {
"*c": "abc": _
"*.txt": "a/b.txt": _
"*.zip": #"c:\a\b\file.zip"#: _
}

Slash: [OS=string]: [ARG=string]: {
to: path.ToSlash(ARG, OS)
from: path.FromSlash(ARG, OS)
Expand Down Expand Up @@ -214,6 +223,52 @@ Clean: {
"c:\\abc\\def\\..\\..": "c:\\"
}
}
Match: {
default: {
"*c": {
abc: true
}
"*.txt": {
"a/b.txt": false
}
"*.zip": {
"c:\\a\\b\\file.zip": true
}
}
unix: {
"*c": {
abc: true
}
"*.txt": {
"a/b.txt": false
}
"*.zip": {
"c:\\a\\b\\file.zip": true
}
}
plan9: {
"*c": {
abc: true
}
"*.txt": {
"a/b.txt": false
}
"*.zip": {
"c:\\a\\b\\file.zip": true
}
}
windows: {
"*c": {
abc: true
}
"*.txt": {
"a/b.txt": true
}
"*.zip": {
"c:\\a\\b\\file.zip": false
}
}
}
Slash: {
unix: {
"": {
Expand Down

0 comments on commit e09cb31

Please sign in to comment.