elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.65k stars 299 forks source link

Add an error handling when duplicated function arguments found #1796

Closed jeffxchu closed 5 months ago

jeffxchu commented 5 months ago

Avoid duplicated arguments in the lambda.

Before we allowed the following fn definition including duplicated args

> fn foo {|x x| puts $x} 

Now we catch duplicated argument 'x' error and display an error message at the compile time in the console. e.g.

> compilation error: [interactive]:1:12-12: duplicate argument name 'x'

Related to https://github.com/elves/elvish/issues/1142