Skip to content

Fix FUNCTION_CALL callee type: use code type instead of Empty#659

Merged
tautschnig merged 4 commits intomainfrom
tautschnig/goto-fix-callee-type
Mar 26, 2026
Merged

Fix FUNCTION_CALL callee type: use code type instead of Empty#659
tautschnig merged 4 commits intomainfrom
tautschnig/goto-fix-callee-type

Conversation

@tautschnig
Copy link
Copy Markdown
Contributor

FUNCTION_CALL callees (e.g., print) had Empty type in the symbol table because coreStmtsToGoto created the callee expression with .Empty type. CBMC instrument_preconditions crashed trying to_code_type on Empty.

Fix: add Ty.Identifier.code and Ty.mkCode, use it for the callee expression in coreStmtsToGoto. The code type flows through collectSymbolRefs into the symbol table naturally.

Fixes 16 Python CBMC tests that use class-related function calls. See PRs like #657 for current failures on that.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

FUNCTION_CALL callees (e.g., print) had Empty type in the symbol table
because coreStmtsToGoto created the callee expression with .Empty type.
CBMC instrument_preconditions crashed trying to_code_type on Empty.

Fix: add Ty.Identifier.code and Ty.mkCode, use it for the callee
expression in coreStmtsToGoto. The code type flows through
collectSymbolRefs into the symbol table naturally.

Fixes 16 Python CBMC tests that use class-related function calls.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent CBMC crashes during precondition instrumentation by ensuring FUNCTION_CALL callee symbols (e.g., print) are given a code type instead of Empty, so the callee’s type flows into the generated symbol table correctly.

Changes:

  • Add a code constructor to CProverGOTO.Ty.Identifier and a Ty.mkCode helper.
  • Extend GOTO JSON serialization (tyToJson) to emit a code type node.
  • Update coreStmtsToGoto to type the function-call callee symbol using Ty.mkCode derived from argument/return expression types.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Strata/Backends/CBMC/GOTO/Type.lean Introduces a code type identifier and Ty.mkCode constructor intended for function-call callees.
Strata/Backends/CBMC/GOTO/InstToJson.lean Adds JSON serialization for the new code type.
Strata/Backends/CBMC/GOTO/CoreToGOTOPipeline.lean Uses Ty.mkCode for FUNCTION_CALL callee expressions instead of .Empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mkCode previously discarded parameter and return types (subtypes was
empty). Now stores them as subtypes = [returnType] ++ paramTypes, and
tyToJson serializes them into proper CBMC code type JSON with parameter
sub-nodes and return_type.

This gives CBMC accurate function signatures for callee symbols rather
than hardcoded empty parameters and void return type.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig enabled auto-merge March 25, 2026 17:08
@tautschnig tautschnig added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit cd519b4 Mar 26, 2026
15 checks passed
@tautschnig tautschnig deleted the tautschnig/goto-fix-callee-type branch March 26, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants