Skip to content

Changing a constant in one class doesn't recompile other classes that reference it #81

Closed
@omgitsraven

Description

@omgitsraven

Describe the bug in detail:
If you make one class reference a constant in another class, and then only change the other class, the first class will have a stale value until you force it to recompile.

Provide steps/code to reproduce the bug:

  1. Make the following U# script and put it on a UdonBehaviour in the scene:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

public class ConstHaver : UdonSharpBehaviour{
	public const int myVal = 3;
}
  1. Make the following U# script and put it on a UdonBehaviour in the scene:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

public class ConstPrinter : UdonSharpBehaviour{
	
	public const int doubleVal = ConstHaver.myVal * 2;
	
	void Start(){
		Debug.Log(doubleVal);
	}
	
}
  1. Enter play mode, and note that the console says 6. Exit play mode.

  2. Edit ConstHaver and change its myVal value to 5.

  3. Enter play mode, and note that the console still says 6. Exit play mode.

  4. Edit ConstPrinter and add Debug.Log("hi"); on a new line after the existing Debug.Log

  5. Enter play mode, and note that the console now says 10 (and then hi).

Expected behavior:
I expected that either the constants would either be set at runtime, or changing one would cause all of the scripts that reference it to be recompiled (or that the readme would warn about this behaviour).

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedBlocked due to being dependent on a larger unimplemented systembugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions