Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Given that methods in custom classes do not support optional parameters (with default values), attempting to define them should fail #9684

Closed
mklement0 opened this issue May 22, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@mklement0
Copy link
Contributor

commented May 22, 2019

Note: If #9701 is implemented, this issue becomes moot.

Steps to reproduce

class Foo {
  # This method definition shouldn't be permitted, because optional parameters
  # aren't supported.
  [string] Bar($Baz = 'Bam') { return $Baz }
}
[Foo]::new().Bar()

Expected behavior

The class definition should fail, given that optional parameters aren't supported.

Actual behavior

The class definition succeeds, but the argument-less invocation of the method fails.

Cannot find an overload for "Bar" and the argument count: "0".

Environment data

PowerShell Core 6.2.1
@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented May 22, 2019

If we implement this error message it will 75% from implementing the feature :-)

@vexx32

This comment has been minimized.

Copy link
Contributor

commented May 22, 2019

Yeah, in truth if we're going to be poking around here I'd rather we make this work properly.

@mklement0

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

I didn't realize that was on the menu.

I'll have the feature then, please :)

@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented May 22, 2019

Maybe reopen with the feature request?

@mklement0

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Good idea; please see #9701

@iSazonov

This comment has been minimized.

Copy link
Collaborator

commented May 23, 2019

@mklement0 Thanks! I think we can close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.