Skip to content

Commit

Permalink
Guarantee order of $f[opt-names] to match definition for function int…
Browse files Browse the repository at this point in the history
…rospection.

Also augment the test of opt-names and opt-defaults to check that.

This fixes #1631.
  • Loading branch information
xiaq committed Dec 31, 2024
1 parent 8d0112c commit 53f77e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/eval/closure_test.elvts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Exception: unsupported options: bad1, bad2
▶ [a b]
~> put {|@r| }[rest-arg]
▶ 0
~> put {|&opt=def| }[opt-names]
▶ [opt]
~> put {|&opt=def| }[opt-defaults]
▶ [def]
~> put {|&opt=def &opt2=def2 &opt0=def0| }[opt-names]
▶ [opt opt2 opt0]
~> put {|&opt=def &opt2=def2 &opt0=def0| }[opt-defaults]
▶ [def def2 def0]
~> put { body }[body]
▶ 'body '
~> put {|x @y| body }[def]
Expand Down
3 changes: 2 additions & 1 deletion website/ref/language.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ user-defined function, it has the following fields:
- `$f[rest-arg]` is the index of the rest argument. If there is no rest
argument, it is `-1`.

- `$f[opt-names]` is a list containing the names of the options.
- `$f[opt-names]` is a list containing the names of the options, in the order
they are defined in the source code.

- `$f[opt-defaults]` is a list containing the default values of the options,
in the same order as `$f[opt-names]`.
Expand Down

0 comments on commit 53f77e6

Please sign in to comment.