Summary:
The Verse compiler is consistently and incorrectly reporting error vErr:S76: Expected block, got “:” following “if” on lines containing standard optional checks using the if (MaybeValue?) syntax. This error code normally relates to the if: … then: failable expression syntax or incorrect colons, but it is being triggered here on lines that do not contain a colon immediately following the if condition and are followed by a correctly indented block. This occurs even when using the standard, documented two-step optional handling pattern.
Description:
While developing a game feature involving triggering prop manipulation based on player state, we encountered persistent S76 errors. These errors initially seemed related to optional unwrapping using if (Value := Optional?), but further investigation revealed the compiler also flags the simpler if (MaybeValue?) check followed by an assignment (Value := MaybeValue.Value) inside the block. The error message specifically claims there is a colon “:” following the if condition’s parenthesis, which is factually incorrect for the code being compiled.
Troubleshooting Steps Taken (Error Persists After Each):
-
Systematically replaced all if (Value := Optional?) syntax with the strict two-step check (MaybeV := Optional?; if (MaybeV?) { V := MaybeV.Value }).
-
Inserted NOP () statements as the first line within if blocks before assignments.
-
Replaced standard for Element : Array: loops with indexed loop constructs.
-
Reverted loops back to standard for.
-
Refactored logic into smaller helper functions.
-
Simplified the script down to a minimal triggerable component.
-
Verified UEFN Installation via Epic Games Launcher.
-
Cleared Project Caches: Deleted Intermediate, .vscode, Saved (including sub-caches) folders from the project directory.
-
Cleared UEFN User Caches: Deleted %localappdata%\UnrealEditorFortnite\DerivedDataCache, Intermediate, and relevant Saved subfolders.
-
Restarted Computer multiple times.
-
Migrated Project Content to a completely new, blank UEFN project.
-
Explicitly specified verse {:version 1.0} at the top of all Verse files.
-
Tested Minimal Code: Reproduced the error even with extremely simplified code in a fresh project (see code snippet below).
Code Snippet Reproducing the Error:
(This is the minimal triggerable script where the error was last confirmed on the if (MaybeAgentInput?) line, or similar lines within it, depending on the exact compiler state)
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Verse.org/Verse/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /Fortnite.com/Game }
using { /UnrealEngine.com/Temporary/WorldPartition } # If using BP Actors
log_prop_follow := log{Channel := "PropFollowMinBug"}
prop_follower_minimal_triggered := class(creative_device):
@editable FollowerActor : creative_object_interface = creative_object_interface{}
@editable ActivationTrigger : trigger_device = trigger_device{}
# Link dummy devices/props in editor for testing compilation
@editable IdleAnim : cinematic_sequence_device = cinematic_sequence_device{}
@editable JogAnim : cinematic_sequence_device = cinematic_sequence_device{}
MoveDuration : float = 0.05
VerticalOffsetZ : float = 90.0
var TrackedFortChar : ?fort_character = false
var TrackedAgent : ?agent = false
var IsFollowing : logic = false
OnBegin<override>()<suspends>:void=
ActivationTrigger.TriggeredEvent.Subscribe(HandleActivation)
GetPlayspace().PlayerRemovedEvent().Subscribe(OnPlayerRemovedCleanup)
log_prop_follow.Print("Minimal Triggerable Follower Initialized.")
HandleActivation(MaybeAgentInput : ?agent):void=
log_prop_follow.Print("Activation Trigger received.")
if (IsFollowing): return
# --- ERROR LIKELY OCCURS ON THIS 'if' or the ones inside it ---
if (MaybeAgentInput?):
Agent := MaybeAgentInput.Value # Assignment using inference
MaybeFortChar := Agent.GetFortCharacter[]
if (MaybeFortChar?):
FortChar := MaybeFortChar.Value
MaybeFollowerObject := FollowerActor.GetObject[]
if (MaybeFollowerObject?):
FollowerObject := MaybeFollowerObject.Value
MaybePlayer := GetPlayspace().GetPlayerForAgent[Agent]
if(MaybePlayer?):
Player := MaybePlayer.Value
log_prop_follow.Print("Activating follow for Agent {Agent}")
CleanupInternalState()
set TrackedAgent = option{Agent}
set TrackedFortChar = option{FortChar}
set IsFollowing = true
FortChar.Hide()
# Simplified placement for testing
FollowerObject.TeleportTo[vector3{X:=0.0, Y:=0.0, Z:=100.0}, IdentityRotation()]
FollowerObject.Show()
spawn { UpdateCharacterLoop(FortChar) }
FortChar.SprintedEvent().Subscribe(OnMoved)
IdleAnim.Play(Agent)
# Else clauses removed for minimal repro
# else Follower object fail
# else FortChar fail
# else Agent fail
UpdateCharacterLoop(CharToFollow : fort_character)<suspends>:void=
loop:
Sleep(0.0)
if(not IsFollowing or not CharToFollow.IsValid[]): break
# Minimal loop logic for test
CleanupInternalState()
OnMoved(MoveData : tuple(fort_character, logic)):void= { } # Empty for test
CleanupInternalState():void= { set IsFollowing = false; set TrackedAgent = false; set TrackedFortChar = false } # Minimal cleanup
OnPlayerRemovedCleanup(PlayerRemoved : player) : void = { } # Empty for test
Expected Result:
The code, using standard Verse syntax for optional checking (if (MaybeValue?)) followed by assignment (Value := MaybeValue.Value), should compile without errors.
Actual Result:
The compiler consistently throws vErr:S76: Expected block, got “:” following “if” pointing to lines like if (MaybeAgentInput?) or the assignment line immediately following it, despite the syntax being valid according to documentation and containing no misplaced colon.
Impact:
This bug makes it impossible to reliably use standard optional checking patterns in certain contexts, severely hindering development and forcing non-standard or broken workarounds. It appears to be a fundamental parser issue specific to the current UEFN environment/version.