Skip to content

Commit 2604c4d

Browse files
author
Maksim Volkau
committed
2 cs print fixes; SixParametersLambdaExpression.GetParameter fixed
1 parent 21a80a5 commit 2604c4d

9 files changed

Lines changed: 9744 additions & 53 deletions

File tree

printcs_20260312-01.out

Lines changed: 9552 additions & 0 deletions
Large diffs are not rendered by default.

result.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,55 @@ Invalid (not compile-able) snippets found in `DebugOutputs/printcs_20260310-01.o
9090

9191
10. **Issue439_Support_unused_Field_access_in_Block.Original_case**
9292
- Contains bare statement `testClass.Result0;`
93-
- Member-access expression alone is not a valid statement expression in C#.
93+
- Member-access expression alone is not a valid statement expression in C#.
94+
95+
## Results003
96+
97+
Review of `printcs_20260312-01.out` (delta vs Results002):
98+
99+
### Fixed since Results002
100+
101+
1. **AssignTests.Array_multi_dimensional_index_assign_value_type_block**
102+
- Previously had invalid declaration like `int[,] int[,]_0 = null;`.
103+
- Now emitted as valid declaration, e.g. `int[,] int__a_0 = null;`.
104+
105+
2. **Issue237_* label-collision cases**
106+
- The previously reported duplicate labels (`bool_0:` / `string_0:` duplicates in same body) are no longer present in the shown snippets.
107+
108+
### Still invalid in 20260312-01
109+
110+
1. **Issue495_Incomplete_pattern_detection...ReturnGotoFromTryCatchWithAssign_ShouldBeDetectedAsError1007**
111+
- Still contains label `return:;`.
112+
- `return` is a keyword and cannot be used as a label identifier.
113+
114+
2. **Issue487_Fix_ToCSharpString_output_for_boolean_equality_expressions.Original_case**
115+
- Snippet is `var @cs = x.MyTestBool;`
116+
- `x` is undeclared in the emitted snippet.
117+
118+
3. **Issue320_Bad_label_content_in_ILGenerator_when_creating_through_DynamicModule.Test_instance_call**
119+
- `Func<int>` body still ends without a `return` statement on all paths.
120+
121+
4. **Issue321_Call_with_out_parameter_to_field_type_that_is_not_value_type_fails.Test_outparameter**
122+
- Still uses `out default(TestPOD)...` as out target.
123+
- `out` requires an assignable variable/storage location.
124+
125+
5. **Issue365_Working_with_ref_return_values.Test_access_ref_returning_method_then_property**
126+
- Still contains `ref pp.GetParamValueByRef().Value = 7;`
127+
- Invalid assignment form in C#.
128+
129+
6. **Issue439_Support_unused_Field_access_in_Block.Original_case**
130+
- Still contains bare member access statement `testClass.Result0;`.
131+
132+
### New invalids noticed in 20260312-01 (not listed in Results002)
133+
134+
1. **Issue428_Expression_Switch_without_a_default_case_incorrectly_calls_first_case_for_unmatched_values**
135+
- Emitted switch has non-empty `case 1:` directly followed by `case 2:` without `break/goto/return`.
136+
- This is C# compile error: control cannot fall through from one case label to another.
137+
138+
2. **Issue422_InvalidProgramException_when_having_TryCatch_Default_in_Catch.Original_case_but_comparing_with_non_null_left_operand**
139+
- Uses `left == ...` where `left` is not declared in snippet.
140+
141+
### Net
142+
143+
- Good progress: multidimensional array declaration and previously duplicated labels appear fixed.
144+
- Remaining compile blockers are still present (keyword-label, missing returns, invalid out target, invalid ref assignment form, bare member-access statement), plus at least two newly observed invalid patterns (switch fall-through and undeclared `left`).

src/FastExpressionCompiler.LightExpression/Expression.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ public static SwitchExpression Switch(Expression switchValue, Expression default
20722072
public static SwitchExpression Switch(Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable<SwitchCase> cases) =>
20732073
Switch(null, switchValue, defaultBody, comparison, cases.AsArray());
20742074

2075-
// The type of the whole switch epxression is void if no default body provided, because what should we return in default case then?
2075+
// The type of the whole switch expression is void if no default body provided, because what should we return in default case then?
20762076
public static SwitchExpression Switch(Expression switchValue, params SwitchCase[] cases) =>
20772077
Switch(typeof(void), switchValue, null, null, cases);
20782078

@@ -5312,8 +5312,8 @@ internal System.Linq.Expressions.LabelTarget ToSystemLabelTarget(ref SmallList<L
53125312
Justification = "The method is used for debugging purposes only.")]
53135313
public override string ToString()
53145314
{
5315-
SmallList<NamedWithIndex, Stack4<NamedWithIndex>, NoArrayPool<NamedWithIndex>> named = default;
5316-
return new StringBuilder().AppendLabelName(this, ref named).ToString();
5315+
PrintContext ctx = default;
5316+
return new StringBuilder().AppendLabelName(this, ref ctx).ToString();
53175317
}
53185318
}
53195319

@@ -5612,7 +5612,7 @@ public class SixParametersLambdaExpression : TypedLambdaExpression
56125612
public sealed override IReadOnlyList<ParameterExpression> Parameters => new[] { Parameter0, Parameter1, Parameter2, Parameter3, Parameter4, Parameter5 };
56135613
public sealed override int ParameterCount => 6;
56145614
public sealed override ParameterExpression GetParameter(int i) =>
5615-
i == 0 ? Parameter0 : i == 1 ? Parameter1 : i == 2 ? Parameter2 : i == 3 ? Parameter3 : i == 5 ? Parameter4 : Parameter5;
5615+
i == 0 ? Parameter0 : i == 1 ? Parameter1 : i == 2 ? Parameter2 : i == 3 ? Parameter3 : i == 4 ? Parameter4 : Parameter5;
56165616
internal SixParametersLambdaExpression(Type delegateType, Expression body,
56175617
ParameterExpression p0, ParameterExpression p1, ParameterExpression p2, ParameterExpression p3,
56185618
ParameterExpression p4, ParameterExpression p5) : base(delegateType, body)

0 commit comments

Comments
 (0)