ID:2714740
 
Resolved
Certain complex expressions with the null conditional operators didn't compile correctly.
BYOND Version:514
Operating System:Windows 10 Pro
Web Browser:Firefox 91.0
Applies to:Dream Maker
Status: Resolved (514.1567)

This issue has been resolved.
Descriptive Problem Summary:
Running this code results in a nonsensical runtime error.
Note that the code is seemingly obtuse in what it does, because it's a minimal test case but it originates from real, useful code that encountered this issue. I managed to narrow it down to this.

Numbered Steps to Reproduce Problem:
Run this in a new project:
Code Snippet (if applicable) to Reproduce Problem:
/mob
var/obj/item/glasses = new
var/obj/abstract/dark_plane = new
/obj/abstract
var/list/alphas = list()
/obj/item
/mob/proc/update_perception()
dark_plane?.alphas[glasses] = glasses

/world/New()
..()
var/mob/M = new
M.update_perception()


Expected Results:
There's no reason why dark_plane's alphas list shouldn't be able to be set to that.
Actual Results:
runtime error: undefined variable /obj/abstract/var/glasses
proc name: update perception (/mob/proc/update_perception)
source file: auxdemo.dm,28
usr: null
src: the mob (/mob)
src.loc: null
call stack:
the mob (/mob): update perception()
world: New()

Does the problem occur:
Every time? Or how often? Every time.
In other games? Yeah.
In other user accounts? Yeah.
On other computers? Yeah.

When does the problem NOT occur?

Changing the last line to
dark_plane?.alphas[glasses] = 1

is sufficient to prevent the crash.
The following is also OK:
dark_plane?.alphas["1"] = glasses


It seems the error only arises when these things are true:
- There's the ?. operator accessing a var
- The var being accessed is a list, or at least something that can be indexed(didn't test indexing datums)
- The index being assigned to is a datum var
- The value being associated with the index is also a datum var

Incredibly specific, I know.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) Didn't test them.

Workarounds:
See above.
Confirmed. There must be something off about the compilation in this case.
Lummox JR resolved issue with message:
Certain complex expressions with the null conditional operators didn't compile correctly.