Code in one of my classes has, after formatting and documenting the class, begun to throw an error wherein a class function, while trying to access a variable of the class on which that function has been called, throws a null reference exception. No code changes have occurred
Numbered Steps to Reproduce Problem:
Code Snippet (if applicable) to Reproduce Problem:
Full code file available in StreamReader.dm in this library.
StreamReader
var
SeekPosition = 1
TextFile
-snip-
proc
EOF(var/Pos = SeekPosition)
. = Pos > lentext(TextFile) // This is line 89
-snip-
Find(var/Needle, var/Start = Index(), var/End = 0)
if (EOF(Start) && End >= 0)
return
if (End < 0)
return findtextEx(TextFile, Needle, End)
. = findtextEx(TextFile, Needle, Start, End)
Expected Results:
Previous behaviour; return the logically expected boolean value of the comparison
Actual Results:
runtime error: Cannot read null.TextFile
proc name: EOF (/StreamReader/proc/EOF)
source file: StreamReader.dm,89
usr: Topkasa (/mob/Soldier)
src: /StreamReader (/StreamReader)
call stack:
/StreamReader (/StreamReader): EOF(1)
/StreamReader (/StreamReader): Find("\"", 1, 0)
Does the problem occur:
Every time? Or how often? Every time
In other games? Not testable
In other user accounts? Not tested
On other computers? Not testable
When does the problem NOT occur?
when lentext(TextFile) is changed to lentext(src.TextFile)
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Worked previously in 501.1216, before formatting with comment blocks.
Workarounds:
Explicitly reference src before attempting to access TextFile