ID:100819
 
Not a bug
BYOND Version:474
Operating System:Windows 7 Home Premium
Web Browser:Chrome 5.0.375.126
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Numbered steps to reproduce the problem:
-Enter the code below into a new DM environment.
-Add a map
Code Snippet (if applicable) to Reproduce Problem:
turf
var/testa/part=new(new/testb())
New()
.=..()
part.add()

testa
var/testb/part
New(p)
.=..()
part=p

proc/add() return part.add()

testb
proc/add()
return 1+1


Expected Results:
testb.add() should be called once for every turf placed on the map.

Actual Results:
The testb object is never instantiated,d a run time error occurs, "Cannot execute null.add()." and the testb.add proc is not called.

Does the problem occur:
Every time? Or how often? Every time
In other games? Yes

When does the problem NOT occur?
I haven't done much testing yet, but I believe that this happens only if the 'original' object is initialized as the server is started (eg here it is placed on the map). Additionally, I have found that if you change the type in the example from turf to obj and put one on the map, then everything works as expected.

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

Workarounds:
Not sure yet.
You're setting var/testa/part=new(new/testb()) at compile-time when the var should be initialized at runtime.
If the code above isn't valid, then shouldn't the compiler catch it? The compiler seems to allow constructors to be called at runtime while giving a 'constant expression required' error for procs.

Anyways, at the very least there is some inconsistent behavior. The next two examples below result in the message being written to the log:
obj
var/test/test=new()

test
New()
.=..()
world.log<<"test"

turf
var/obj/test=new()

obj
New()
.=..()
world.log<<"test"

But this doesn't:
turf
var/test/test=new()

test
New()
.=..()
world.log<<"test"