Skip to content

Fix unhandled exception when accessing machine fields (fixes #920)#939

Merged
ankushdesai merged 1 commit intomasterfrom
fix/issue-920-machine-field-access
Mar 11, 2026
Merged

Fix unhandled exception when accessing machine fields (fixes #920)#939
ankushdesai merged 1 commit intomasterfrom
fix/issue-920-machine-field-access

Conversation

@ankushdesai
Copy link
Member

The P compiler was throwing an ArgumentOutOfRangeException when code attempted to access fields of a machine reference (e.g., server.database). This change restricts machine field access to PVerifier contexts only (proof blocks), producing a proper type error in regular P code.

Changes:

  • Add isPVerifier flag to ExprVisitor to control machine field access
  • Guard PermissionType and PrimitiveType.Machine field access with isPVerifier
  • Enable isPVerifier in Analyzer.cs and ProofBlockVisitor.cs
  • Conditionally enable in StatementVisitor based on PVerifier output mode

Test cases added:

  • MachineFieldAccess: Direct machine field access
  • MachineFieldAccessNested: Chained machine field access
  • MachineFieldAccessInExpr: Machine field in arithmetic expression

The P compiler was throwing an ArgumentOutOfRangeException when code
attempted to access fields of a machine reference (e.g., server.database).
This change restricts machine field access to PVerifier contexts only
(proof blocks), producing a proper type error in regular P code.

Changes:
- Add isPVerifier flag to ExprVisitor to control machine field access
- Guard PermissionType and PrimitiveType.Machine field access with isPVerifier
- Enable isPVerifier in Analyzer.cs and ProofBlockVisitor.cs
- Conditionally enable in StatementVisitor based on PVerifier output mode

Test cases added:
- MachineFieldAccess: Direct machine field access
- MachineFieldAccessNested: Chained machine field access
- MachineFieldAccessInExpr: Machine field in arithmetic expression
@ankushdesai ankushdesai merged commit 5a8b0df into master Mar 11, 2026
10 checks passed
@ankushdesai ankushdesai deleted the fix/issue-920-machine-field-access branch March 11, 2026 20:34
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.

1 participant