Skip to content

Commit

Permalink
adds warning to scope weirdness, removes nullability marker from Expr…
Browse files Browse the repository at this point in the history
…essionContext. Proc
  • Loading branch information
Ruzihm committed Feb 24, 2025
1 parent f0a290c commit cef6c73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DMCompiler/DM/Builders/DMExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ private DMExpression BuildScopeIdentifier(DMASTScopeIdentifier scopeIdentifier,
if (scopeMode is Normal && ctx.Proc != null) {

Check warning

Code scanning / InspectCode

Expression is always true according to nullable reference types' annotations Warning

Expression is always true according to nullable reference types' annotations
if (ctx.Proc.GetLocalVariable(identifier.Identifier) != null) {
// actually - it's referring to a local variable named "type" or "parent_type"... just do the usual thing
Compiler.Emit(WarningCode.SoftReservedKeyword, identifier.Location,
$"Using scope operator :: on a variable named \"type\" or \"parent_type\" is ambiguous. Consider changing the variable name from \"{identifier.Identifier}\".");
expression = BuildExpression(scopeIdentifier.Expression, inferredPath);
} else {
return BadExpression(WarningCode.BadExpression, identifier.Location,
Expand Down
4 changes: 2 additions & 2 deletions DMCompiler/DM/DMExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ private void VerifyArgType(DMCompiler compiler, DMProc targetProc, int index, st
}
}

internal readonly struct ExpressionContext(DMCompiler compiler, DMObject type, DMProc? proc) {
internal readonly struct ExpressionContext(DMCompiler compiler, DMObject type, DMProc proc) {
public readonly DMCompiler Compiler = compiler;
public readonly DMObject Type = type;
public readonly DMProc? Proc = proc;
public readonly DMProc Proc = proc;

public DMObjectTree ObjectTree => Compiler.DMObjectTree;
}

0 comments on commit cef6c73

Please sign in to comment.