warn when fewer returns than expected are given for a function

This commit is contained in:
Ricardo Luís Vaz Silva 2023-10-15 11:21:07 -03:00 committed by Christoph Oelckers
parent e2a9208c56
commit d699ba248e
3 changed files with 10 additions and 4 deletions

View file

@ -11330,6 +11330,10 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
{
mismatchSeverity = MSG_ERROR;
}
else if (protoRetCount > retCount)
{ // also warn when returning less values then the return count
mismatchSeverity = MSG_WARNING;
}
}
if (mismatchSeverity != -1)

View file

@ -210,7 +210,7 @@ class StateProvider : Inventory
action Actor, Actor A_FireProjectile(class<Actor> missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0)
{
let player = self.player;
if (!player) return null;
if (!player) return null, null;
let weapon = player.ReadyWeapon;
@ -220,7 +220,7 @@ class StateProvider : Inventory
if (useammo && weapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
{
if (!weapon.DepleteAmmo(weapon.bAltFire, true))
return null; // out of ammo
return null, null; // out of ammo
}
if (missiletype)

View file

@ -122,11 +122,13 @@ extend class Object
native static double G_SkillPropertyFloat(int p);
deprecated("3.8", "Use Level.PickDeathMatchStart() instead") static vector3, int G_PickDeathmatchStart()
{
return level.PickDeathmatchStart();
let [a,b] = level.PickDeathmatchStart();
return a, b;
}
deprecated("3.8", "Use Level.PickPlayerStart() instead") static vector3, int G_PickPlayerStart(int pnum, int flags = 0)
{
return level.PickPlayerStart(pnum, flags);
let [a,b] = level.PickPlayerStart(pnum, flags);
return a, b;
}
deprecated("4.3", "Use S_StartSound() instead") native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);
native static void S_StartSound (Sound sound_id, int channel, int flags = 0, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);