Skip to content

feat(js/ts/python/dart/beam): support ArgumentException.ParamName - #5203

Merged
MangelMaxime merged 5 commits into
fable-compiler:mainfrom
leonitousconforti:support-argument-paramname
Oct 29, 2026
Merged

MangelMaxime merged 5 commits into
fable-compiler:mainfrom
leonitousconforti:support-argument-paramname

Conversation

@leonitousconforti

Copy link
Copy Markdown
Contributor

Lets Fable code read ArgumentException.ParamName (also through ArgumentNullException and ArgumentOutOfRangeException) on JS/TS, Python, Dart and Beam, where it was a compile error. One commit per target.

  • JS/TS, Python, Dart: ParamName calls the library's existing getter. On JS/TS and Python, constructors without a name now store null/None instead of "", so ParamName is null as on .NET. Messages don't change.
  • Beam: argument exception maps get a param_name key, set by invalidArg, nullArg, the constructors that take a name, and the argument checks in fable_list, fable_resize_array and fable_int. ArgumentOutOfRangeException(paramName, actualValue, message) used the name as its message; it now gives message (Parameter 'paramName').
  • Python: this changes what existing constructors store. AGENTS.md asks for new names when semantics change, so I can switch to that if you prefer.

Difference from .NET: on Dart, a missing ParamName reads "", since Dart strings aren't nullable.

Not covered:

  • Rust, which can't type-test BCL exceptions.
  • Library names that are now visible and differ from .NET: List.exactlyOne says list (FSharp.Core: source), JS/TS List.transpose says array.[0], and JS/TS Random.Next and Queue(capacity) pass their message as the name.
  • ArgumentNullException(message, inner) and the other ArgumentOutOfRangeException constructors on JS/TS, Python and Dart.
  • On Beam, nullArgCheck still raises badarg.

Whichever of this PR and #5154 lands second will add param_name to #5154's fable_list:argument_out_of_range/2.

leonitousconforti and others added 5 commits October 29, 2026 19:45
Map ArgumentException.ParamName (also read through ArgumentNullException
and ArgumentOutOfRangeException) to the getter the library already has,
instead of failing to compile. Constructors without a parameter name now
store null rather than "", so an absent ParamName reads as null like on
.NET. Messages are unchanged.
Map ArgumentException.ParamName to the getter the Dart library already
has, instead of failing to compile. Dart strings are not nullable, so an
absent parameter name keeps reading as an empty string.
Map ArgumentException.ParamName (also read through ArgumentNullException
and ArgumentOutOfRangeException) to the getter the library already has,
instead of failing to compile. Constructors without a parameter name now
store None rather than "", so an absent ParamName reads as null like on
.NET. Messages are unchanged.
Argument exception maps now carry a param_name key, which
ArgumentException.ParamName reads (undefined, so null, when there is
none). The compiler adds it for invalidArg, nullArg and the
ArgumentException, ArgumentNullException and ArgumentOutOfRangeException
constructors that take a parameter name, evaluating the name once, and
the library adds it where fable_list, fable_resize_array and fable_int
raise argument exceptions (fable_decimal already did). Messages are
unchanged, except that ArgumentOutOfRangeException(paramName,
actualValue, message) no longer uses the parameter name as its message
and the message as its inner exception.
@MangelMaxime
MangelMaxime force-pushed the support-argument-paramname branch from eba7733 to 6afb778 Compare October 29, 2026 18:50
@MangelMaxime
MangelMaxime merged commit 8ed7778 into fable-compiler:main Oct 29, 2026
36 checks passed
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.

2 participants