Skip to content

add a fail test for Issue499#501

Merged
dadhi merged 3 commits intodadhi:masterfrom
bluewingHuang:issue-499-addtest
Apr 9, 2026
Merged

add a fail test for Issue499#501
dadhi merged 3 commits intodadhi:masterfrom
bluewingHuang:issue-499-addtest

Conversation

@bluewingHuang
Copy link
Copy Markdown

test output

//Issue499_InvalidProgramException_for_Sorting_and_comparison_function.ArrayInList_ArrayAcceesError
var _ = (Action<List<Nullable[]>>)((List<Nullable[]> dataArrayList) => //void
{
int left_ListIndex = default;
int left_ArrayIndex = default;
int? left_0 = null;
left_ListIndex = 0;
left_ArrayIndex = 0;
left_0 = dataArrayList[left_ListIndex][left_ArrayIndex];
});
<ArrayInList_ArrayAcceesError>
IL_0000: ldc.i4.0
IL_0001: stloc.0
IL_0002: ldc.i4.0
IL_0003: stloc.1
IL_0004: ldarg.1
IL_0005: ldloc.0
IL_0006: callvirt Nullable[] List<Nullable[]>.get_Item(Int32)
IL_0011: ldloc.1
IL_0012: ldelem int?
IL_0017: stloc.2
IL_0018: ret
</ArrayInList_ArrayAcceesError>
<ArrayInList_ArrayAcceesError>
IL_0000: ldc.i4.0
IL_0001: stloc.0
IL_0002: ldc.i4.0
IL_0003: stloc.1
IL_0004: ldarg.1
IL_0005: ldloca.s V_0
IL_0007: callvirt Nullable[] List<Nullable[]>.get_Item(Int32)
IL_0012: ldloc.1
IL_0013: ldelem int?
IL_0018: stloc.2
IL_0019: ret
</ArrayInList_ArrayAcceesError>

@bluewingHuang
Copy link
Copy Markdown
Author

I added a fix, and all original tests of https://github.com/bluewingHuang/FastExpressionCompiler/blob/SortCompileError/CompileTest/SortCompilerTests.cs now pass. please review.

@dadhi
Copy link
Copy Markdown
Owner

dadhi commented Apr 9, 2026

Hi @bluewingHuang

var _ = (Action<List<Nullable[]>>)((List<Nullable[]> dataArrayList) => //void

Is it really outputs Nullable indtead of Nullable?

public void ArrayInList_ArrayAcceesError(TestContext t)
{
List<Expression> exps = new List<Expression>();
var dataArrayList = Parameter(typeof(List<int?[]>), "dataArrayList");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead int? the array will contain SomeStruct?
and the final access will drill to the int? field of this struct,
e.g. like dataArrayList[x][y].Foo where Foo is int? SomeStruct.Foo.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a problem with this fix, or do I need to add more unit tests?

@bluewingHuang
Copy link
Copy Markdown
Author

Hi @bluewingHuang

var _ = (Action<List<Nullable[]>>)((List<Nullable[]> dataArrayList) => //void

Is it really outputs Nullable indtead of Nullable?

I Changed the return value void and added several new unit tests. The unit tests for Struct were passing even before the fix.

@dadhi
Copy link
Copy Markdown
Owner

dadhi commented Apr 9, 2026

I don't get it. Doed PrintCSharp output Nullable[] or Nullable[]?

@bluewingHuang
Copy link
Copy Markdown
Author

I don't get it. Doed PrintCSharp output Nullable[] or Nullable[]?

It was Nullable[]. I didn't edit the output and I can't reproduce it. All the new runs print:

var _ = (Action<List<Nullable<int>[]>>)((List<Nullable<int>[]> dataArrayList) => //void

@dadhi
Copy link
Copy Markdown
Owner

dadhi commented Apr 9, 2026

Ok. Great. Thank you for the QR and fix. Merging

@dadhi dadhi merged commit 6c8479a into dadhi:master Apr 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants