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

Implement for(k,v in L) syntax #2241

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ike709
Copy link
Collaborator

@ike709 ike709 commented Mar 9, 2025

@boring-cyborg boring-cyborg bot added Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime labels Mar 9, 2025
@github-actions github-actions bot added the size/L label Mar 9, 2025
@ike709
Copy link
Collaborator Author

ike709 commented Mar 9, 2025

Requires #2240 for CI to pass.

@ike709 ike709 requested a review from wixoaGit March 9, 2025 13:40
Comment on lines +281 to +286
var outputVal = state.GetReferenceValue(outputRef);
state.GetReferenceValue(assocRef);
var listVal = state.GetReferenceValue(listRef);
var indexVal = state.GetIndex(listVal, outputVal, state);

state.AssignReference(assocRef, indexVal);
Copy link
Member

Choose a reason for hiding this comment

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

AssignReference() needs done in the correct order same as GetReferenceValue(). You're gonna need to reorder the opcode's arguments to have assocRef last.

@@ -453,7 +453,60 @@
ProcessStatementVarDeclaration(new DMASTProcStatementVarDeclaration(statementFor.Location, decl.DeclPath, null, DMValueType.Anything));
}

if (statementFor.Expression2 != null || statementFor.Expression3 != null) {
if (statementFor.Expression2 is DMASTExpressionIn dmastIn && statementFor.Expression3 is null) {

Check notice

Code scanning / InspectCode

Merge null/pattern checks into complex pattern Note

Merge into pattern
@@ -598,16 +651,29 @@
proc.AddLabel(endLabel2);
} else {
DMReference outputRef = lValue.EmitReference(ExprContext, null);
proc.Enumerate(outputRef);
if (assocValue != null && list != null) {
DMReference assocRef = assocValue.EmitReference(ExprContext, null);

Check warning

Code scanning / InspectCode

Cannot convert null literal to non-nullable reference type. Warning

Cannot convert null literal to non-nullable reference type
proc.Enumerate(outputRef);
if (assocValue != null && list != null) {
DMReference assocRef = assocValue.EmitReference(ExprContext, null);
DMReference listRef = list.EmitReference(ExprContext, null);

Check warning

Code scanning / InspectCode

Cannot convert null literal to non-nullable reference type. Warning

Cannot convert null literal to non-nullable reference type
lValue = new BadLValue(outputAssocVar.Location);
}

LValue? outputValue = (LValue)outputAssocVar!;

Check warning

Code scanning / InspectCode

Variable can be declared as non-nullable Warning

'outputValue' can be declared as non-nullable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants