ID:2641668
 
Resolved
A fix for the ?. operator caused problems when it was used in certain expressions.
BYOND Version:513.1537
Operating System:Windows 10 Pro 64-bit
Web Browser:Chrome 87.0.4280.88
Applies to:Dream Maker
Status: Resolved (513.1538)

This issue has been resolved.
Descriptive Problem Summary:
Some RHS expressions with the ?. operator just fail to compile now.

Numbered Steps to Reproduce Problem:
Use the code snippet

Code Snippet (if applicable) to Reproduce Problem:
/world/New()
var/x = src?.type

Expected Results:
Compilation

Actual Results:
Fails to compile

Does the problem occur:
Every time? Or how often? yes
In other games? yes
In other user accounts? n/a
On other computers? yes

When does the problem NOT occur?
When you don't meet the special cases

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
513.1536

Workarounds:
none
Lummox JR resolved issue with message:
A fix for the ?. operator caused problems when it was used in certain expressions.
I have a fix for this standing by, but I may hold off on releasing it immediately if there are other odd cases that come in.

So far the only case where I've seen this to be an issue is when it's in a var definition, which explains why it escaped my testing. Var defs apparently do some very weird stuff.
I'm also getting a compiler error on compound assignment.

The following code:
mob/var/chatting

mob/verb/Test()
src?.chatting--


Yields an invalid expression compiler error.
In response to Spevacus
Updated with a fix for this as well. My original fix did not handle this case.

The two cases handled so far are:

var/N = A?.B  // ?. used in a var definition

A?.B++ // pre- or post-increment/decrement

If anyone else finds a new case not already handled, or you aren't sure, please be sure to pile on.
I'm getting another one, but I can't make a test case at the moment:

Error:
<expression>.variable: undefined type /unrelated_type/same_name


Specifically, my code is like this if you have any ideas:
/some_object/proc_override()
member?.variable = null


For some reason, the undefined type it thinks it is, instead of a variable on the member, is named the same thing as the last part of the typepath.

So, the typepath would be like obj/foo, while the variable on the member is member?.foo.

Kinda weird, and vague, but it worked fine before this.

Edit: Looked over and fixed this, it was some weird travelling syntax error from some old unused part of the code that somehow surfaced here, probably due to the identifier being named the same.
Using a proc call in this way also does not compile:
var/A = B?.do_something()

Most likely the same issue as with var/A = B?.C
In response to Farie82
Yeah, that would fall under the var definition case.