Skip to content
New issue

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

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

Already on GitHub? # to your account

All optional method arguments are default past first argument that defaults. #171

Open
Soggy-Pancake opened this issue Sep 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Soggy-Pancake
Copy link

Describe the bug in detail:
All optional arguments after the first optional argument that defaults appear to also default, even if they are given a value when calling.

Provide steps/code to reproduce the bug:
Steps or code to reproduce the behavior.

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

public class OptionalTest : UdonSharpBehaviour
{
    void optionalArg(string str, int check = 0) {
		Debug.Log($"Optional arg test! Optional ver: str {str}  int {check}");
	}

    void moreOptionalArg(string str, int check = 0, int doubleCheck = 0, float evenMoreNum = 0f) {
		Debug.Log($"Optional arg test! Required ver: str {str}  int: {check} doubleCheck: {doubleCheck}, evenMore: {evenMoreNum}");
	}

    void requiredArg(string str, int check) {
		Debug.Log($"Optional arg test! Required ver: str {str}  int {check}");
	}

    void Start()
    {
        Debug.Log("Optional arg test! START");
        optionalArg("optional1", check: 25);
        requiredArg("required2", 17);
        moreOptionalArg("maybeBroken", doubleCheck: 69);
        moreOptionalArg("idk Anymore", check: -5, doubleCheck: -8);
	moreOptionalArg("maybeJustFirst?", check: 69);
        moreOptionalArg("even MORE testing", check: 8, evenMoreNum: 8.4f);

	}
}

image

Log as text:

Optional arg test! START
Optional arg test! Optional ver: str optional1  int 25
Optional arg test! Required ver: str required2  int 17
Optional arg test! Required ver: str maybeBroken  int: 0 doubleCheck: 0, evenMore: 0        (doubleCheck should be 69)
Optional arg test! Required ver: str idk Anymore  int: -5 doubleCheck: -8, evenMore: 0       (correct)
Optional arg test! Required ver: str maybeJustFirst?  int: 69 doubleCheck: 0, evenMore: 0    (correct)
Optional arg test! Required ver: str even MORE testing  int: 8 doubleCheck: 0, evenMore: 0    (evenMore is missing)

Expected behavior:

Optional arg test! START
Optional arg test! Optional ver: str optional1  int 25
Optional arg test! Required ver: str required2  int 17
Optional arg test! Required ver: str maybeBroken  int: 0 doubleCheck: 69, evenMore: 0
Optional arg test! Required ver: str idk Anymore  int: -5 doubleCheck: -8, evenMore: 0
Optional arg test! Required ver: str maybeJustFirst?  int: 69 doubleCheck: 0, evenMore: 0
Optional arg test! Required ver: str even MORE testing  int: 8 doubleCheck: 0, evenMore: 8.4

Additional Information:
Environment:
Script was placed on an empty object in the root of the hierarchy.

Package Versions: (Latest as of making bug report)
VRC SDK - Worlds: 3.7.1
VRC Package resolver tool: 0.1.29
VRC SKD - Base: 3.7.1

@Soggy-Pancake Soggy-Pancake added the bug Something isn't working label Sep 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant