Skip to content

IDL Problem Code 101 with alias var-use-before-def

Want to disable me? Check out the configuration guide to learn more.

Execution Error

This is a fatal error that prevents IDL from compiling or running code

This problem identifies when you use a variable before it has been defined.

Here's an example:

idl
print, myVar
;      ^^^^^ used before def
myVar = 42

To fix, re-order or re-write your code:

idl
myVar = 42
print, myVar
;      ^^^^^ OK!

Catch Blocks

If you are encountering this error in catch blocks, then you can try re-writing your code to follow the style of JavaScript/TypeScript try/catch blocks:

idl
catch, err
if (err ne 0) then begin
  print, myvar
  ;      ^^^^^ used before definition
endif
myvar = 42
idl
catch, err
if (err eq 0) then begin
  myvar = 42
endif else begin
  print, myvar
  ;      ^^^^^ OK!
endelse

Licensed under MIT.