Forum > General

Hint: Local variable xx of a managed type does not seem to be initialized

(1/4) > >>

Igor Kokarev:
After updating to Lazarus 2.0.0 I found a new type of Hint messages:

"Hint: Local variable xx of a managed type does not seem to be initialized"

This hint didn't appear in previous v1.8.4.

I didn't find an option in Messages of a project options to hide this hint message.

For my project I consider this hint useless.

lucamar:
That message was present also in Lazarus 1.8.x (and IIRC in 1.6.x). It appears, for example, in code like:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{deleted, see example below}
It's normally useless but not always. That's (I suppose) why it is a hint rather than a warning.

Never seen it before? Lucky you!  :)

ETA: One example (Lazarus/FPC 1.8.4/3.0.4)

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---lucamar@selene:~/SoftDev/Minipad$ lazbuild minipad.lpiInfo: (lazarus) Execute Title="Compile Project, Mode: Release, Target: minipad"Info: (lazarus) Working Directory="/home/lucamar/SoftDev/Minipad/"{... pruned some lines ...}{***** See? This is Lazarus 1.8.4 *****}Info: (lazarus) Param[9]="-Fu/usr/share/lazarus/1.8.4/lcl/units/i386-linux/gtk2"{... pruned some more lines ...}Info: (lazarus) Param[17]="minipad.lpr"Hint: (11030) Start of reading config file /etc/fpc.cfgHint: (11031) End of reading config file /etc/fpc.cfgFree Pascal Compiler version 3.0.4 [2018/05/21] for i386Copyright (c) 1993-2017 by Florian Klaempfl and others(1002) Target OS: Linux for i386(3104) Compiling minipad.lpr(3104) Compiling fmain.pas{***** HERE is one (nonsense) "not initialized" hint *****}/home/lucamar/SoftDev/Minipad/fmain.pas(250,12) Hint: (5092) Variable "FindStr" of a managed type does not seem to be initialized/home/lucamar/SoftDev/Minipad/fmain.pas(98,26) Hint: (5024) Parameter "Sender" not used{... pruned lots of these kind of hint ...}/home/lucamar/SoftDev/Minipad/fmain.pas(120,28) Hint: (5024) Parameter "Sender" not used(9022) Compiling resource /home/lucamar/SoftDev/Minipad/lib/i386-linux/minipad.or(9015) Linking minipad/usr/bin/ld: warning: link.res contains output sections; did you forget -T?(1008) 825 lines compiled, 18.0 sec(1022) 21 hint(s) issued
That line is inside a function declared as:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TMain.FindInMemo(FindStr: String; var FindFrom: Integer;  Options: TFindOptions = DefFindOptions): Boolean;
The line itself is just
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  { "Match case" uses both texts as they are; if not ... }  if not (frMatchCase in Options) then begin    SrcText := LowerCase(SrcText);    FindStr := LowerCase(FindStr);  end; 
The hint is non-sense because I have already tested whether FindStr = ''; so to avoid seeing it (in Lazarus only!) I just add a {%H-} before the line:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if not (frMatchCase in Options) then begin    SrcText := LowerCase(SrcText);    {%H-}FindStr := LowerCase(FindStr);  end; and done!

ASerge:

--- Quote from: lucamar on February 05, 2019, 06:00:40 pm ---It appears, for example, in code like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Something(var AString: AnsiString);begin  if AString = '' then {<--- This gives the hint}    AString := DoX(AString)  else    AString := AString + DoX(AString);end;
--- End quote ---
Are you sure?
This code compiles without any hints, even with -Oodfa

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$MODE OBJFPC} procedure Something(var AString: AnsiString);begin  if AString = '' then    AString := AString + '1'  else    AString := AString + '2';end; var  S: AnsiString;begin  S := '';  Something(S);end.

lucamar:

--- Quote from: ASerge on February 05, 2019, 11:25:55 pm ---<snip>
Are you sure?
<snip>
--- End quote ---

Yes, although I marked the wrong line; the hint goes to the next: AString := DoX(AString) and my guess is it's about the call to DoX(AString), as can be seen in the second, real-life example I added. However that first example you cite is not up to par so I've deleted it from my post.

Well, WTH? I just tested with this simple program:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program test; {$mode objfpc}{$H+} uses sysutils; var sv: String;  function DoX(AString: String): String;begin  Result := LowerCase(AString);end; procedure Something(var AString: String);begin  if AString = '' then    AString := DoX(AString)  else    AString := AString + ' = ' + DoX(AString);end; begin  { Pass an empty string }  sv := '';  Something(sv);  writeln(sv);  { Pass a non-empty string }  sv := 'I''m just a simple string...';  Something(sv);  writeln(sv);end.
and you're right: it doesn't generate any hint whatsoever.
:-[

Anyway, the point was that it's not a new hint ...

Igor Kokarev:
Hi,

Thanks for your reply. I agree that these hints can be useful.

However the problem in a fact that it is NOT possible to hide this hint (5091) from a popup menu in Lazarus in Messages window.

Edited: See new message below.

I choose "Filter all messages of type: Hint (5091) variable "$1" of a managed type does not seem to be initialized"

and nothing happens, I still see these hints in Messages window, even if I restart Lazarus.

Also this hint doesn't exist in Project Options > Messages.

The only way to hide hint 5091 is to add an option -vm5091 in Project Options > Custom Options

Navigation

[0] Message Index

[#] Next page

Go to full version