When JS, operations on pointer casted from ref object raises Runtime-Errors
### Description

There are two kinds of errors I've found:

Given here are two variables:
```Nim
type O = ref object
var p1, p2: O
```

1. `TypeError: Cannot read properties of null (reading 'undefined')`
```Nim
func `+`(a: pointer): int = cast[int](a)
discard +cast[pointer](p1)
```

2. `SyntaxError: Unexpected token '=='`

```Nim
discard cast[pointer](p1) == cast[pointer](p2)
```
(here an odd `==` token is generated with no operands)
And I know `p1 == p2` just works and is preferred.

### Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-06-27
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 828cd58d8a0376a5b7a6ad58d73d66617b37629a
active boot switches: -d:release


### Current Output

1.
```text
    result_520093703 = a_p0[a_p0_Idx];
                           ^
TypeError: Cannot read properties of null (reading 'undefined')
```

2.
```txt
(( ==  && p1_520093699[0] == p2_520093700[0]));
   ^^
SyntaxError: Unexpected token '=='
```


### Expected Output

```text
(runs without error)
```


### Possible Solution

_No response_

### Additional Information

For the second, if:
```Nim
func `+`(a, b: pointer): int = cast[int](a) + cast[int](a)
discard cast[pointer](p1) + cast[pointer](p2)
```

Then error is:
```txt
    result_520093707 = addInt(a_p0[a_p0_Idx], a_p0[a_p0_Idx]);
                                                           ^

TypeError: Cannot read properties of null (reading 'null')
```

donno why the two operands are just the same.