HaxeFoundation / HaxeFoundation/haxe

null Abstract @:to

Open
#4,555 5 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following error was reported by an user https://github.com/HaxeFoundation/neko/issues/54
While investigating it, I found that what happens is that when doing:

```
var o : Null = null;
trace("Result = "+o);
```

Translate to:

```
trace("Result = "+Std.string(o.toFloat());
```

And the toFloat() performs a `null + 0.` addition which triggers an exception.

I could easily fix it by patching UInt, but I wonder if we should not find another way. For instance for all nullable abstracts, a toString() would check first for (if( o == null ) "null" else o.toString()).

What do you think @Simn ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.