Calling initial() on type, parent_type, and potentially other constant built-in vars yield compiler errors
Code Snippet (if applicable) to Reproduce Problem:
/world/New()
var/datum/y = /datum/a
log << "[initial(y.type)]"
log << "[initial(y.parent_type)]"
var/datum/a/x = new
log << "[initial(x.type)]"
log << "[initial(x.parent_type)]"
del(src)
/datum/a
var/whatever = 4
Expected Results:
/datum/a
/datum
/datum/a
/datum
Actual Results:
loading asdf.dme
asdf.dm:5:error: y.type: cannot change constant value
asdf.dm:6:error: y.parent_type: cannot change constant value
asdf.dm:8:error: x.type: cannot change constant value
asdf.dm:9:error: x.parent_type: cannot change constant value
asdf.dmb - 4 errors, 0 warnings (7/27/17 10:40 am)
Does the problem occur:
Every time? Or how often? Every time
In other games? Yes
In other user accounts? Yes
On other computers? Yes
When does the problem NOT occur? Never
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Unknown
Workarounds:
/proc/type2parent(child)
var/string_type = "[child]"
var/last_slash = findlasttext(string_type, "/")
if(last_slash == 1)
switch(child)
if(/datum)
return null
if(/obj || /mob)
return /atom/movable
if(/area || /turf)
return /atom
else
return /datum
return text2path(copytext(string_type, 1, last_slash))