Skip to content

Fix $try, silent operator and custom functions control flow - #422

Open
Daaisukidayo wants to merge 4 commits into
tryforge:alphafrom
Daaisukidayo:fix/try-silent-custom-functions
Open

Daaisukidayo wants to merge 4 commits into
tryforge:alphafrom
Daaisukidayo:fix/try-silent-custom-functions

Conversation

@Daaisukidayo

Copy link
Copy Markdown
Contributor
  • $try: $return, $break, $continue, and $stop functions are passed to the calling code rather than triggering the catch block, JavaScript exceptions are caught and logged via ctx.noop, the result of a catch block correctly handles the ! and @[] operators
  • #: Works for functions nested within other functions. A "silent error" is converted into a Stop object containing error information, allowing it to be caught using $try
  • Custom functions: The function body is processed via resolveCode instead of Interpreter.run, errors are returned to the calling code rather than being sent to a channel, $break and $continue functions affect the loop in the calling code
  • $callLocalFunction: Passes $stop, $break, $continue, and errors back to the calling code
  • ReturnValue<ReturnType.Stop> now corresponds to the type Error | null

… errors, the silent operator not working on nested functions and custom functions, $break and $continue in custom functions not affecting loops, and $callLocalFunction ignoring $stop, $break, $continue and errors
@xNickyDev xNickyDev added not tested Bug has not been reproduced patch labels Nov 25, 2026
…tom-functions

# Conflicts:
#	docs/assets/hierarchy.js
#	docs/classes/ApplicationCommand.html
#	docs/classes/ApplicationCommandManager.html
#	docs/classes/Arg.html
#	docs/classes/BaseCommand.html
#	docs/classes/BaseCommandManager.html
#	docs/classes/BaseEventHandler.html
#	docs/classes/CompiledFunction.html
#	docs/classes/Compiler.html
#	docs/classes/Container.html
#	docs/classes/Context.html
#	docs/classes/CooldownManager.html
#	docs/classes/DiscordEventHandler.html
#	docs/classes/EventManager.html
#	docs/classes/FileReader.html
#	docs/classes/ForgeClient.html
#	docs/classes/ForgeError.html
#	docs/classes/ForgeExtension.html
#	docs/classes/ForgeFunction.html
#	docs/classes/ForgeFunctionManager.html
#	docs/classes/FunctionManager.html
#	docs/classes/Interpreter.html
#	docs/classes/InviteTracker.html
#	docs/classes/Logger.html
#	docs/classes/NativeCommandManager.html
#	docs/classes/NativeFunction.html
#	docs/classes/Return.html
#	docs/classes/ThreadManager.html
#	docs/classes/VoiceTracker.html
#	docs/enums/ArgType.html
#	docs/enums/CalendarType.html
#	docs/enums/ErrorType.html
#	docs/enums/HTTPContentType.html
#	docs/enums/LogPriority.html
#	docs/enums/LogType.html
#	docs/enums/OperatorType.html
#	docs/enums/PrefixMode.html
#	docs/enums/RegistrationType.html
#	docs/enums/ReturnType.html
#	docs/functions/array.html
#	docs/functions/defineProperties.html
#	docs/functions/generateMetadata.html
#	docs/hierarchy.html
#	docs/interfaces/IApplicationCommandData.html
#	docs/interfaces/IArg.html
#	docs/interfaces/IAutomodRuleOptions.html
#	docs/interfaces/IBaseCommand.html
#	docs/interfaces/ICommandManagerEvents.html
#	docs/interfaces/ICompilationResult.html
#	docs/interfaces/ICompiledCommand.html
#	docs/interfaces/ICompiledFunction.html
#	docs/interfaces/ICompiledFunctionConditionField.html
#	docs/interfaces/ICompiledFunctionField.html
#	docs/interfaces/IComponentOptions.html
#	docs/interfaces/IContextCache.html
#	docs/interfaces/ICooldown.html
#	docs/interfaces/IEvent.html
#	docs/interfaces/IExtendedCompilationResult.html
#	docs/interfaces/IExtendedCompiledFunction.html
#	docs/interfaces/IExtendedCompiledFunctionConditionField.html
#	docs/interfaces/IExtendedCompiledFunctionField.html
#	docs/interfaces/IForgeClientOptions.html
#	docs/interfaces/IForgeFunction.html
#	docs/interfaces/IForgeFunctionParam.html
#	docs/interfaces/IGuildInvite.html
#	docs/interfaces/IGuildInviter.html
#	docs/interfaces/IHttpOptions.html
#	docs/interfaces/ILocalFunctionData.html
#	docs/interfaces/ILocation.html
#	docs/interfaces/IMultipleArgResolve.html
#	docs/interfaces/INativeFunction.html
#	docs/interfaces/IRawField.html
#	docs/interfaces/IRawForgeClientOptions.html
#	docs/interfaces/IRawFunction.html
#	docs/interfaces/IRawFunctionFieldDefinition.html
#	docs/interfaces/IRawFunctionMatch.html
#	docs/interfaces/IRestrictions.html
#	docs/interfaces/IRunnable.html
#	docs/interfaces/IScheduledEventOptions.html
#	docs/interfaces/IStates.html
#	docs/interfaces/IThreadContext.html
#	docs/interfaces/IThreadResult.html
#	docs/interfaces/IThreadTask.html
#	docs/interfaces/ITrackers.html
#	docs/types/AnyNativeFunction.html
#	docs/types/AssertArgs.html
#	docs/types/ClassInstance.html
#	docs/types/ClassType.html
#	docs/types/CommandInteractionTypes.html
#	docs/types/CommandType.html
#	docs/types/EnumLike.html
#	docs/types/ExpectCallback.html
#	docs/types/ExtendedField.html
#	docs/types/FilterProperties.html
#	docs/types/GetArgType.html
#	docs/types/GetEnum.html
#	docs/types/GetErrorArgs.html
#	docs/types/MarkNullable.html
#	docs/types/MarkRest.html
#	docs/types/NativeFunctionExecutor.html
#	docs/types/OverwritePermission.html
#	docs/types/Properties.html
#	docs/types/RawExecutableCode.html
#	docs/types/RecursiveArray.html
#	docs/types/ResolveFields.html
#	docs/types/ReturnValue.html
#	docs/types/Sendable.html
#	docs/types/States.html
#	docs/types/UnwrapArg.html
#	docs/types/UnwrapArgs.html
#	docs/types/WrappedCode.html
#	docs/types/WrappedConditionCode.html
#	docs/variables/COMMAND_INTERACTION_TYPES.html
#	docs/variables/Conditions.html
#	docs/variables/NativeEventName.html
#	docs/variables/Operators.html
#	metadata/changelogs.json
#	metadata/enums.json
#	metadata/functions.json
#	metadata/translations/en.json

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked not tested Bug has not been reproduced patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants