question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local object vars inaccessible in static var declaration

See original GitHub issue

When attempting to compile /vg/station, the following error occurs: Error at code\game\machinery\atmoalter\canister.dm:128:14: Unknown identifier "icon" at the following location:

126 /obj/machinery/portable_atmospherics/canister/proc/pressure_overlays(var/state)
127 	var/static/list/status_overlays_pressure = list(
128 		image(icon, "can-o0"),
129 		image(icon, "can-o1"),
130 		image(icon, "can-o2"),
131 		image(icon, "can-o3")
132 	)
133 
134 	return status_overlays_pressure[state]

It seems that it doesn’t recognize it’s own icon as a var, or else it’s conflicting with the fact that the first arg of image() is also called icon, or something.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wixoaGitcommented, Jun 17, 2022

Yes, that’s exactly it.

It’s the same way in BYOND, it just silently errors and treats it as null

0reactions
Exxioncommented, Jun 18, 2022

Yes, pretty much. It might be helpful to have the error message give more information in the specific case of accesses in static var initialization, but if that’s not simple to implement it seems fine as-is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

static member variable inside a local class in c++?
I'd give up pretty quickly :) No access to local variables from local class: because class instance might outlive the function scope. Example:...
Read more >
6.10 — Static local variables
In this lesson, we'll explore the use of the static keyword when applied to a local variable. Static local variables.
Read more >
C++ Tutorial: Static Variables and Static Class Members
A variable declared static within a module (but outside the body of a function) is accessible by all functions within that module. However,...
Read more >
How do I make a variable accessible across my project?
I need a variable that will be accessible from my main target, and an imported Framework. A Global Variable doesn't work as it's...
Read more >
Static Keyword - Manual
Because static methods are callable without an instance of the object created, the pseudo-variable $this is not available inside methods declared as static....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found