Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with empty initializer #632

Merged
merged 3 commits into from
Sep 7, 2024

Conversation

kant2002
Copy link
Collaborator

No description provided.

@ForNeVeR ForNeVeR self-requested a review August 31, 2024 20:17
@ForNeVeR ForNeVeR self-assigned this Aug 31, 2024
@ForNeVeR
Copy link
Owner

ForNeVeR commented Sep 2, 2024

For structs/struct_init.c, this yields a runtime error:

[ERR] Unhandled exception. System.InvalidProgramException: The JIT compiler encountered invalid IL code or an internal limitation.
[ERR]    at main()
[ERR]    at <SyntheticEntrypoint>()
[ERR] 
Command exit code: -532462766

@ForNeVeR
Copy link
Owner

ForNeVeR commented Sep 3, 2024

I think @kant2002 mentioned he still works on this one.

if (i != 0)
{
instructions.Add(Instruction.Create(OpCodes.Ldc_I4, i));
instructions.Add(Instruction.Create(OpCodes.Sizeof, element)); // size = sizeof(array element)
instructions.Add(Instruction.Create(OpCodes.Mul)); // offset = id * size
instructions.Add(Instruction.Create(OpCodes.Add)); // offset = id * size
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like the comment is wrong. What does this actually do?

instructions.Add(Instruction.Create(OpCodes.Ldloc, newobj)); // push new object
if (_prefixAction is not null)
{
_prefixAction();
Copy link
Owner

Choose a reason for hiding this comment

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

Is it okay that _prefixAction gets called twice? Let's maybe write some comment about its purpose and possible behavior?

Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

I have to say that I don't like the business around prefixAction and postfixAction boo much, but if it works, then it works.

Thanks!

@ForNeVeR ForNeVeR merged commit c98dfb7 into ForNeVeR:main Sep 7, 2024
3 checks passed
@kant2002 kant2002 deleted the kant/struct-initialization branch September 8, 2024 06:06
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