From ce0f7ba4421c92eaf8db86c4599ba661cc06bde0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:36:09 +0000 Subject: [PATCH 1/3] Initial plan From bfc1fc7d5d048cfab139e9a4bcce530b5b89ef9e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:54:36 +0000 Subject: [PATCH 2/3] Fix compiler warnings across the project Agent-Logs-Url: https://github.com/jonathanvdc/Flame/sessions/f6e123c5-be46-4cf7-95ad-9e1ddb9246c2 Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com> --- src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs | 8 ++++---- src/Flame.Compiler/Flow/ReturnFlow.cs | 2 +- src/Flame.Compiler/Flow/SwitchFlow.cs | 2 +- src/Flame.Ir/ConstantCodec.cs | 13 ++++++++++--- src/Flame.Ir/DecoderState.cs | 4 ++-- src/Flame.Ir/EncoderState.cs | 4 ++-- src/Flame.Ir/InstructionCodecElements.cs | 4 ++-- src/Flame.Ir/TypeCodec.cs | 2 +- src/Flame/ContractHelpers.cs | 5 ----- src/UnitTests/Flame/DeferredInitializerTests.cs | 2 +- 10 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs b/src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs index 2a2f54459..99846aa97 100644 --- a/src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs +++ b/src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs @@ -289,8 +289,8 @@ private void AnalyzeExceptionHandler( /// Analyzes a 'catch' exception handler's implementation. /// /// The exception handler to analyze. - /// - /// The basic block tag of the landing pad to populate for the handler. + /// + /// The analyzed catch handler to populate. /// /// A CIL method body. private void AnalyzeCatchHandler( @@ -344,8 +344,8 @@ private void AnalyzeCatchHandler( /// Analyzes a 'filter' exception handler's implementation. /// /// The exception handler to analyze. - /// - /// The basic block tag of the landing pad to populate for the handler. + /// + /// The analyzed filter handler to populate. /// /// A CIL method body. private void AnalyzeFilterHandler( diff --git a/src/Flame.Compiler/Flow/ReturnFlow.cs b/src/Flame.Compiler/Flow/ReturnFlow.cs index 66ccd5084..b534d26bf 100644 --- a/src/Flame.Compiler/Flow/ReturnFlow.cs +++ b/src/Flame.Compiler/Flow/ReturnFlow.cs @@ -35,7 +35,7 @@ public override BlockFlow WithInstructions(IReadOnlyList instructio { ContractHelpers.Assert(instructions.Count == 1, "Return flow takes exactly one instruction."); var newReturnValue = instructions[0]; - if (object.ReferenceEquals(newReturnValue, ReturnValue)) + if (newReturnValue.Equals(ReturnValue)) { return this; } diff --git a/src/Flame.Compiler/Flow/SwitchFlow.cs b/src/Flame.Compiler/Flow/SwitchFlow.cs index 621f70206..cd1362dfc 100644 --- a/src/Flame.Compiler/Flow/SwitchFlow.cs +++ b/src/Flame.Compiler/Flow/SwitchFlow.cs @@ -185,7 +185,7 @@ public override BlockFlow WithInstructions(IReadOnlyList instructio { ContractHelpers.Assert(instructions.Count == 1, "Switch flow takes exactly one instruction."); var newSwitchValue = instructions[0]; - if (object.ReferenceEquals(newSwitchValue, SwitchValue)) + if (newSwitchValue.Equals(SwitchValue)) { return this; } diff --git a/src/Flame.Ir/ConstantCodec.cs b/src/Flame.Ir/ConstantCodec.cs index c69def892..2ec9cdb0f 100644 --- a/src/Flame.Ir/ConstantCodec.cs +++ b/src/Flame.Ir/ConstantCodec.cs @@ -75,9 +75,8 @@ public override LNode Encode(Constant value, EncoderState state) { // Encode other integer constants as custom literals. return state.Factory.Literal( - new CustomLiteral( - integerConst.Value.ToString(), - GSymbol.Get(integerConst.Spec.ToString()))); + integerConst.Value.ToString(), + GSymbol.Get(integerConst.Spec.ToString())); } } else if (value is Float32Constant) @@ -253,6 +252,7 @@ private static bool TryDecomposeCustomLiteral( out Symbol typeMarker) { var val = node.Value; +#pragma warning disable CS0618 // Keep CustomLiteral support for backward compatibility with older encoded IR if (val is CustomLiteral) { var literal = (CustomLiteral)val; @@ -260,6 +260,13 @@ private static bool TryDecomposeCustomLiteral( typeMarker = literal.TypeMarker; return true; } +#pragma warning restore CS0618 + else if (node.TypeMarker != null) + { + value = val; + typeMarker = node.TypeMarker; + return true; + } else { value = null; diff --git a/src/Flame.Ir/DecoderState.cs b/src/Flame.Ir/DecoderState.cs index 533a025f1..86e47303a 100644 --- a/src/Flame.Ir/DecoderState.cs +++ b/src/Flame.Ir/DecoderState.cs @@ -828,7 +828,7 @@ private BlockFlow DecodeBlockFlow( return UnreachableFlow.Instance; } } - else if (node.Calls(CodeSymbols.Switch)) + else if (node.Calls(CodeSymbols.SwitchStmt)) { // Decode the value being switched on as well as the default branch. Instruction switchVal; @@ -907,7 +907,7 @@ private BlockFlow DecodeBlockFlow( Quotation.QuoteEvenInBold( "unknown type of flow; expected one of ", CodeSymbols.Goto.Name, ", ", - CodeSymbols.Switch.Name, ", ", + CodeSymbols.SwitchStmt.Name, ", ", CodeSymbols.Try.Name, ", ", CodeSymbols.Return.Name, " or ", EncoderState.unreachableFlowSymbol.Name, ".")); diff --git a/src/Flame.Ir/EncoderState.cs b/src/Flame.Ir/EncoderState.cs index b584f20d3..da68c7059 100644 --- a/src/Flame.Ir/EncoderState.cs +++ b/src/Flame.Ir/EncoderState.cs @@ -36,7 +36,7 @@ public EncoderState(IrCodec codec, LNodeFactory factory) public EncoderState(IrCodec codec) : this( codec, - new LNodeFactory(EmptySourceFile.Default)) + new LNodeFactory(EmptySourceFile.Synthetic)) { } /// @@ -457,7 +457,7 @@ private LNode Encode( } return Factory.Call( - CodeSymbols.Switch, + CodeSymbols.SwitchStmt, Encode(switchFlow.SwitchValue, valueNameMap), Encode(switchFlow.DefaultBranch, blockNameMap, valueNameMap), Factory.Call(CodeSymbols.Braces, caseNodes)); diff --git a/src/Flame.Ir/InstructionCodecElements.cs b/src/Flame.Ir/InstructionCodecElements.cs index 3b8eb81ab..a97102666 100644 --- a/src/Flame.Ir/InstructionCodecElements.cs +++ b/src/Flame.Ir/InstructionCodecElements.cs @@ -242,7 +242,7 @@ private static IReadOnlyList EncodeIndirectCall(IndirectCallPrototype val return new LNode[] { state.Encode(value.ResultType), - state.Factory.List(paramTypeNodes) + state.Factory.AltList(paramTypeNodes) }; } @@ -279,7 +279,7 @@ private static IReadOnlyList EncodeIntrinsic(IntrinsicPrototype value, En { state.Factory.Id(value.Name), state.Encode(value.ResultType), - state.Factory.List(paramTypeNodes) + state.Factory.AltList(paramTypeNodes) }; } diff --git a/src/Flame.Ir/TypeCodec.cs b/src/Flame.Ir/TypeCodec.cs index 47c275b04..11466f86b 100644 --- a/src/Flame.Ir/TypeCodec.cs +++ b/src/Flame.Ir/TypeCodec.cs @@ -39,7 +39,7 @@ private TypeCodec() public static readonly TypeCodec Instance = new TypeCodec(); private static readonly Symbol pointerSymbol = GSymbol.Get("#pointer"); - private static readonly Symbol genericParameterSymbol = CodeSymbols.PtrArrow; + private static readonly Symbol genericParameterSymbol = CodeSymbols.RightArrow; private Dictionary pointerKindEncoding; private Dictionary pointerKindDecoding; diff --git a/src/Flame/ContractHelpers.cs b/src/Flame/ContractHelpers.cs index 7fe16b6a3..f6ca34236 100644 --- a/src/Flame/ContractHelpers.cs +++ b/src/Flame/ContractHelpers.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Flame { @@ -8,15 +7,11 @@ namespace Flame /// public static class ContractHelpers { - [Serializable] private class AssertionException : Exception { public AssertionException() { } public AssertionException(string message) : base(message) { } public AssertionException(string message, Exception inner) : base(message, inner) { } - protected AssertionException( - SerializationInfo info, - StreamingContext context) : base(info, context) { } } /// diff --git a/src/UnitTests/Flame/DeferredInitializerTests.cs b/src/UnitTests/Flame/DeferredInitializerTests.cs index 0bf4ad519..69d2be26b 100644 --- a/src/UnitTests/Flame/DeferredInitializerTests.cs +++ b/src/UnitTests/Flame/DeferredInitializerTests.cs @@ -71,7 +71,7 @@ public void TestMultithreadedInit() public void RecursiveInit() { var integer = new Box(0); - DeferredInitializer init; + DeferredInitializer init = default; // This test makes sure that Initialize() does not recurse: // calling Initialize() from Initialize() does nothing at all. // This is by design, because it allows initialization to touch From 760f0cab61e5de76ab5e02d95910c7580722f26e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 18:19:07 +0000 Subject: [PATCH 3/3] Fix TryDecomposeCustomLiteral to skip default '_' type marker Agent-Logs-Url: https://github.com/jonathanvdc/Flame/sessions/5c800215-2c4b-45b3-80fa-41236afddbc7 Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com> --- src/Flame.Ir/ConstantCodec.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Flame.Ir/ConstantCodec.cs b/src/Flame.Ir/ConstantCodec.cs index 2ec9cdb0f..a66e7addf 100644 --- a/src/Flame.Ir/ConstantCodec.cs +++ b/src/Flame.Ir/ConstantCodec.cs @@ -261,7 +261,7 @@ private static bool TryDecomposeCustomLiteral( return true; } #pragma warning restore CS0618 - else if (node.TypeMarker != null) + else if (node.TypeMarker != null && node.TypeMarker.Name != "_") { value = val; typeMarker = node.TypeMarker;