Skip to content

Reject duplicate function parameters#876

Open
rohan-patnaik wants to merge 1 commit into
google:masterfrom
rohan-patnaik:reject-duplicate-params
Open

Reject duplicate function parameters#876
rohan-patnaik wants to merge 1 commit into
google:masterfrom
rohan-patnaik:reject-duplicate-params

Conversation

@rohan-patnaik
Copy link
Copy Markdown

Rejects duplicate parameter names while parsing function and method parameter lists.

Previously, go-jsonnet accepted inputs like:

(function(x, x, x) x)(null, 3, 2)

That makes argument/default handling ambiguous and differs from other Jsonnet implementations, which reject duplicate parameters.

This change tracks parameter names while parsing and returns a static error when the same name appears twice. It covers normal functions, local function sugar, and object methods.

Fixes #873.

Testing:

  • go test ./internal/parser
  • go test ./...

@He-Pin
Copy link
Copy Markdown
Contributor

He-Pin commented May 22, 2026

Great, does the same problem exist in cpp?

@CertainLach
Copy link
Copy Markdown

CPP is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go-jsonnet does not reject duplicate parameter definition

3 participants