Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Fix i64.gt to return bool (#208)#209

Open
bibonix wants to merge 2 commits into
objectionary:masterfrom
bibonix:fix/i64-gt-returns-bool
Open

Fix i64.gt to return bool (#208)#209
bibonix wants to merge 2 commits into
objectionary:masterfrom
bibonix:fix/i64-gt-returns-bool

Conversation

@bibonix
Copy link
Copy Markdown

@bibonix bibonix commented Apr 28, 2026

@yegor256 this PR closes #208.

Problem

eo2js-runtime/src/objects/org/eolang/i64$gt.js wrapped its boolean comparison result in phi.take('org.eolang.i64').with({0: data.toObject(...)}), with two consequences:

  1. Wrong return type. i64.gt returned an org.eolang.i64 instead of a bool, inconsistent with number.gt (which returns data.toObject(bool) directly).
  2. Crash in standalone contexts. phi.take('org.eolang.i64') walks objects/org/eolang/ looking for an i64 package or i64.js file, neither of which exists in the runtime, so any call to i64.gt aborted with Error: Couldn't find object 'i64' from 'org.eolang.i64'.

Fix

Mirror number$gt.js and return data.toObject(bool) directly. The unused phi import is dropped.

obj.assets[LAMBDA] = function(self) {
  return data.toObject(
    dataized(self.take(RHO), LONG) > dataized(self.take('x').take('as-i64'), LONG)
  )
}

Tests

Added eo2js-runtime/test/objects/org/eolang/i64$gt.test.js covering both branches:

  • 7L > 3L dataizes to true
  • 5L > 10L dataizes to false

Both tests fail on master with Couldn't find object 'i64' from 'org.eolang.i64' and pass with this change. The full grunt task (mocha + eslint) is green locally and on CI (16/16 checks). Ready for merge.

bibonix added 2 commits April 28, 2026 16:15
The lambda of `i64.gt` calls `phi.take('org.eolang.i64')`, which fails
with "Couldn't find object 'i64' from 'org.eolang.i64'" in standalone
contexts where `org.eolang.i64` is not registered. The test asserts
the comparison result dataized as `bool`, mirroring `number$gt`.
`i64.gt` wrapped its boolean comparison result in
`phi.take('org.eolang.i64').with(...)`, returning an `i64` instead of
a `bool` and crashing in standalone contexts where `org.eolang.i64`
isn't registered. Mirror `number$gt` and return `data.toObject(bool)`
directly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i64.gt returns org.eolang.i64 instead of bool

1 participant