HaxeFoundation / HaxeFoundation/haxe

Int64 operators crash when null

Open
#12,387 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The `Int64` class is supported using two backing `Int`s, and when performing operators, it needs to access those two backing `Int`s. However, none of the operators do any form of null checking and this leads to crashes when `Int64` is nullable. `Int32` differs in this regard, since it ends up treating null as 0. Here's just one of many examples where this issue occurs:
```haxe
final i:Int64 = 123;
final n:Int64 = null;
trace(i == n); // TypeError: can't access property "high", n is null

final i:Int32 = 123;
final n:Int32 = null;
trace(i == n); // false
```

I can't find any information about this behaviour, but I'm assuming this is a bug since the behaviour doesn't coincide with `Int32` or `Int` and can lead to weird gotchas

Contributor guide

Open the contributing guide

Research direction

Start by locating the Int64 operator implementations and comparing their null handling with Int32. Reproduce the equality example from the issue, then determine the intended behavior for nullable Int64 operations. Done means the affected operators no longer crash unexpectedly and the behavior is covered consistently.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.