Skip to content

affect the failBlock so it can be return in case of error - #19735

Open
stella-pas-rose wants to merge 7 commits into
pharo-project:Pharo14from
stella-pas-rose:19641
Open

affect the failBlock so it can be return in case of error #19735
stella-pas-rose wants to merge 7 commits into
pharo-project:Pharo14from
stella-pas-rose:19641

Conversation

@stella-pas-rose

Copy link
Copy Markdown
Contributor

we applied the suggested correction! :)

nextIntegerBase: aRadix ifFail: aBlock
	"Form an integer with optional sign and following digits from sourceStream."

	| isNeg value |
	failBlock := [ aBlock value ].
	
	isNeg := self peekSignIsMinus.
	value := self nextUnsignedIntegerOrNilBase: aRadix.
	value ifNil: [^aBlock value].
	^isNeg
		ifTrue: [value negated]
		ifFalse: [value]

@Solomanoa

Close #19618

@guillep guillep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice Thanks!!

@guillep

guillep commented May 29, 2026

Copy link
Copy Markdown
Member

The doc comments fail with an exception:

Integer class>>#readFrom:ifFail:: Doc comment is not well formed. Content: self readFrom: '\' ifFail: [false] >>> false

Traza de la pila

Error
Integer class>>#readFrom:ifFail:: Doc comment is not well formed. Content: self readFrom: '\' ifFail: [false] >>> false
PharoDocCommentExpression(Object)>>error:
PharoDocCommentExpression>>evaluate
CommentTestCase>>evaluate
CommentTestCase>>testIt
CommentTestCase(TestCase)>>performTest

Comment thread src/NumberParser/Integer.extension.st Outdated
Comment thread src/NumberParser/Integer.extension.st Outdated
Comment thread src/NumberParser/Integer.extension.st
Comment on lines +317 to +318
failBlock := [ ^ aBlock value ].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The failBlock is meant to be culled with error and position, so it shouldn't be wrapped in a no-args block.

Suggested change
failBlock := [ ^ aBlock value ].
failBlock := aBlock.

@Gabriel-Darbord

Gabriel-Darbord commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Adding a test would be great, so the intended culling behavior is preserved.

@Ducasse

Ducasse commented Jun 16, 2026

Copy link
Copy Markdown
Member

Hi gabriel

I'm not sure but the changes are not equivalent because the [ ^ aBlock value ] acts as an exception (It was probably the way they coded exception before exception.
So we have to check this aspect.

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.

Integer class>>#readFrom:ifFail: throws an error instead of calling the fail block in some cases

5 participants