From e09cb310d52d5b8a55cfa0e6eecd02d84db11b1f Mon Sep 17 00:00:00 2001 From: Noam Dolovich Date: Thu, 6 Jun 2024 16:29:03 +0300 Subject: [PATCH] pkg/path: add missing param declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: I6e645293f8e589ad1834e3c33ff7bffc2abb5aed Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195888 Reviewed-by: Daniel Martí Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo --- pkg/path/pkg.go | 1 + pkg/path/testdata/os.txtar | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/pkg/path/pkg.go b/pkg/path/pkg.go index 9cdd35016b6..813242e370b 100644 --- a/pkg/path/pkg.go +++ b/pkg/path/pkg.go @@ -122,6 +122,7 @@ var p = &pkg.Package{ }, { Name: "Match", Params: []pkg.Param{ + {Kind: adt.StringKind}, {Kind: adt.StringKind}, {Kind: adt.StringKind, Value: unixDefault}, }, diff --git a/pkg/path/testdata/os.txtar b/pkg/path/testdata/os.txtar index 6a036d50b28..b92f46d9036 100644 --- a/pkg/path/testdata/os.txtar +++ b/pkg/path/testdata/os.txtar @@ -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) @@ -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: { "": {