Skip to content

Commit

Permalink
nil should type as int
Browse files Browse the repository at this point in the history
  • Loading branch information
ivojawer committed Aug 24, 2023
1 parent 8b418d2 commit b14f31c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions smalltalksrc/Slang-Tests/SlangBasicTypeInferenceTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SlangBasicTypeInferenceTest >> testANilConstantNode [
tMethod := ccg methodNamed: #aNilConstantNode.

self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #sqInt
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #int
]

{ #category : #constant }
Expand Down Expand Up @@ -198,7 +198,7 @@ SlangBasicTypeInferenceTest >> testReturnANilConstantNode [
tMethod := ccg methodNamed: #returnANilConstantNode.

self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #sqInt.
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #int.
self assert: tMethod returnType equals: #sqInt
]

Expand Down Expand Up @@ -717,9 +717,9 @@ SlangBasicTypeInferenceTest >> testReturnTempNilConstantNode [
tMethod := ccg methodNamed: #returnTempNilConstantNode.

self assert: tMethod isNotNil.
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #sqInt. " assignementNode "
self assert: (ccg typeFor: tMethod statements first value in: tMethod) asString equals: #sqInt. " value, constantNode "
self assert: (ccg typeFor: tMethod statements first variable in: tMethod) asString equals: #sqInt. " variable, temporaryNode "
self assert: (ccg typeFor: tMethod statements first in: tMethod) asString equals: #int. " assignementNode "
self assert: (ccg typeFor: tMethod statements first value in: tMethod) asString equals: #int. " value, constantNode "
self assert: (ccg typeFor: tMethod statements first variable in: tMethod) asString equals: #int. " variable, temporaryNode "

self assertReturnTypeOf: tMethod equalsHarmonized: #sqInt
]
Expand Down
2 changes: 1 addition & 1 deletion smalltalksrc/Slang/TConstantNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TConstantNode >> typeOrNilFrom: aCodeGenerator in: aTMethod [
^ #'long long' ] ].
value isFloat ifTrue: [ ^ #double ].
(#(true false) includes: value) ifTrue: [^TType boolean].
value ifNil: [ ^ TType sqInt ].
value ifNil: [ ^ TType int ].
(value isString and: [ value isSymbol not ]) ifTrue: [ ^ #'char *' ].
^ nil
]
Expand Down

0 comments on commit b14f31c

Please sign in to comment.