Pharo test defects

Cog: primitiveDoNamedPrimitiveWithArgs: PrimErrNotFound

State
Fixed in a Cog patch (not sent)
Defect in
stock Cog VM v12.0.6
Tests
1
Fix
cog-named-primitive-not-found.patch
Upstream repository
pharo-project/pharo-vm

Record

Test

"Run in a Playground of a Pharo 14 image."
| r |
r := CodeSimulationTest new veryBasicAt: 1.
{ r. (Context sender: nil receiver: nil method: Object >> #at: arguments: #(10)) push: nil; push: 500;
	doPrimitive: 117 method: CodeSimulationTest >> #veryBasicAt: receiver: CodeSimulationTest new args: #(999) }
"Stock Cog: {#'not found'. {token. nil}}: the simulation loses the error code.  With the change the two agree."

Names such as scripts/vmrun.sh and scripts/cogdiff/ are scripts of the iospharo repository, which runs one VM at a time. cog is stock Cog, cogp is Cog with the change, ours is iospharo.

Fix

A change of the Cog sources (pharo-project/pharo-vm, branch pharo-12), on the local branch fix/named-primitive-not-found-in-simulation. State: committed on the branch, tested. Not sent upstream.

cog-named-primitive-not-found.patch (download)
From d60074f617fd8b7ca8ec8ce6616ea9ce61aabcaa Mon Sep 17 00:00:00 2001
From: Aaron Wohl
Date: Tue, 17 Nov 2026 07:39:09 -0500
Subject: [PATCH] primitiveDoNamedPrimitiveWithArgs: PrimErrNotFound when the
 function does not exist

primitiveExternalCall fails with PrimErrNotFound when a named primitive
does not exist, so <primitive: 'name' module: 'm' error: code> gets
#'not found' in code.  primitiveDoNamedPrimitiveWithArgs, which the image
uses to simulate the same call (Context>>tryNamedPrimitiveIn:for:withArgs:),
failed with the generic code -1 for the same case, and the simulation
answered nil as the error code.

CodeSimulationTest>>testErrorCodeNotFound compares the two answers.  The
image has the test set to skip.  With this change the test passes with the
skip removed.

Measured on macOS 27, arm64, a Debug build:
  real call, before and after:  #'not found'
  simulated call, before:       nil
  simulated call, after:        #'not found'

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---
 smalltalksrc/VMMaker/StackInterpreterPrimitives.class.st | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/smalltalksrc/VMMaker/StackInterpreterPrimitives.class.st b/smalltalksrc/VMMaker/StackInterpreterPrimitives.class.st
index 3e19d3e0a..8ebbf3489 100644
--- a/smalltalksrc/VMMaker/StackInterpreterPrimitives.class.st
+++ b/smalltalksrc/VMMaker/StackInterpreterPrimitives.class.st
@@ -913,7 +913,7 @@ StackInterpreterPrimitives >> primitiveDoNamedPrimitiveWithArgs [
 				         addressOf: metaAccessorDepth
 				         put: [ :val | metaAccessorDepth := val ]).
 	addr = 0 ifTrue: [ metaAccessorDepth := -2 ].
-	addr = 0 ifTrue: [ ^ self primitiveFailFor: -1 ]. "could not find function; answer generic failure (see below)"
+	addr = 0 ifTrue: [ ^ self primitiveFailFor: PrimErrNotFound ]. "could not find function; the same code as primitiveExternalCall gives for the real call"
 
 	"Cannot fail this primitive from now on.  Can only fail the external primitive."
 	tempOop := objectMemory
-- 
2.54.0 (Apple Git-157)

State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.