The Causes of "Accessed None""

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

MrBond

ZHP Founder
Sep 23, 2003
452
0
16
USA
zerohour-productions.net
I was looking through the UWiki the other day, trying to find the cause of "Accessed None" in some mutator code of mine (which I solved). In my travels, I came across three different causes, and thought it best to share them with my fellow BU'ers, and also ask for help in identifying other causes:

1) Variable is "none" or "null"
-- Variable not initialized or initialized to "none"
2) Non-existent array index
-- Array index does not exist
3) Improper type cast
-- Variable cannot be cast to the specified type

If anyone knows of other causes, please post them. As always, I will continue to search....
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
The only cause for an Accessed None is when you try to access an object variable's member while the variable holds the value "None". This in turn can happen due to various reasons.

The simple case:
An object variable containing None.

A more complex case:
An array index outside the array bounds was accessed. This causes an individual "Accessed array index out of bounds" error and returns a null value, which in case of an object array means "None". An integer array would return 0 and a string array would return an empty string. Accessing the return value's members causes the Accessed None warning.

Recursive Accessed None:
When accessing a property of an object variable that is None, an Accessed None warning is logged and a null value is returned. Now if you try to access a member of that value, the obvious consequence is another Accessed None. For example:
Code:
function Test()
{
  local Object O;

  log(O.Outer.Class);
}
This function declares the (empty) local variable "O". Then the Log() function tries to access the Class member of the Object stored in O's property "Outer". Of course O has not been initialized, so an "Accessed None" is logged when trying to access O.Outer. However, the script doesn't stop here. "O.Outer" evaluates to "None" after logging the warning and this object's "Class" member is accessed. Again an Accessed None is logged, because O.Outer is None. So again the expression ("O.Outer.Class") evaluates to None, which is passed to the Log() function.
The resulting log will contain:

ScriptWarning: Accessed None
ScriptWarning: Accessed None
ScriptLog: None


A variation of the Accessed None warning is the "Accessed null class context" warning, which will happen when trying to access default properties of a class stored in a variable:
Code:
function NullClass()
{
  local class<Actor> aClass;

  log(aClass.default.AmbientGlow);
}
The variations for Accessed Nones described above also apply to null class accessing. The result of accessing a null class context also is a null value.


And there's another variation of the Accessed None: "Attempt to assign variable through None"
This warning is generated when you try to assign a value to a member of an empty object variable. The variations of Accessed None warnings apply here as well, especially the array out of bounds variant. It is worth reminding that assigning to an invalid element of a dynamic array extends the array and fills it with null values if and only if the index is greater 0 and the assignment directly affects the array and not a member of an array element. (Array[x] = y will work, while Array[x].y = z will log an array out of bounds error and possibly an attempt to assign variable through None)


Further reading:
UnrealWiki: Log Warnings