SmileBASIC (2 and 3), 94.5 bytes
Thank you 12Me21 for helping out.
?3+CANCEL In SB, variable declaration rules are lazy by default; if a variable name is not declared or assigned anywhere in scope, it is assumed to be 0. There's also a handful of reserved system variables and constants which varies between version and platform.
In SB v2, CANCEL was a reserved variable that represented -1; this was intended for use with RESULT to check the state of a dialog box or other action. In SB v3, this variable is not present.
Thus, when this program is run on a standard SB v2 environment it prints 2, and on a v3 environment it prints 3.