ID:2521435
 
BYOND Version:512
Operating System:Windows 10 Pro 64-bit
Web Browser:Chrome 80.0.3952.0
Applies to:Dream Daemon
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary: This has probably been an issue for as long as I've been on BYOND and I'm finally fed up with it pointing me in the wrong direction.

Numbered Steps to Reproduce Problem:

1) Use below code.
2) See "Cannot create objects of type null" runtime error instead of something useful.

Code Snippet (if applicable) to Reproduce Problem:
mob/verb/Break()
new "/obj"(loc) // works, strings are converted to paths when needed, which is good.
new "/obj/nonsense" // Useless runtime error.


This becomes especially problematic in places where you're saving and loading data and the runtime points to a generic line that works 100% fine for everything else. It's also impossible to actually add a check to see if this'll work, you have to try/catch it, but it's better to actually fix the problem by having a descriptive runtime tell you what type is failing.

Expected Results:
"Cannot create objects of type /obj/nonsense"
Actual Results:
"Cannot create objects of type null"
Does the problem occur: Anytime you use an invalid type anywhere a valid type is expected, places where you turn strings into types are the easy ones to find.
Every time? Or how often? Every time.
In other games? Yep
In other user accounts? Yep
On other computers? Yep

When does the problem NOT occur?

It's a runtime error thing, it's something you either avoid or don't.

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.)

Has been this way for at least 10 years, but I recall it being this way when I started.

Workarounds:

Use valid types! There's no soft-code way to determine if a type is valid or not, just whether it's a type or not.
text2path returns null for non-existent paths, no?
Mmhmm, which would be usable for checking if it's valid but it seems to get a little touchy with datums using parent types; which is another issue I need to work out a testcase for. Since it's not happening as consistently as I thought it was.

I actually believe that behavior of text2path() might be why the runtime error shows null, since it's probably doing the same conversion internally when new gets a string.
Another issue I've noticed in the same area is if you accidentally pass an instance instead of a type, you get a confusing error:

var/t = new /datum
var/v = new t // Cannot create objects of type /datum.


That one took a while to figure out when I first encountered it - maybe it should say something like Cannot create objects of type <instance of /datum>

Edit: Turns out I already reported this nearly three years ago :D