Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seemingly mistaken "reference to unknown object: <object>" warning #8

Open
JacquesRobin opened this issue Jan 9, 2020 · 10 comments
Open

Comments

@JacquesRobin
Copy link

I am getting a:
refasModel.lgt:32: Warning: Reference to unknown object: list
But on line 32 in that file I just have:
:- uses(list, [append/3]).
and in my loader file I have:
:- initialization(logtalk_load([ loops(loader), meta(loader), types(loader), refasModel ])).

Since Logtalk's list object is part of its types library, why is it unknown?

The only non-comments line I have before 32 in refasModel.lgt are:
:- object(metaclass, instantiates(metaclass)).
:- public(new/2).
new(Instance, Clauses) :-
self(Class),
create_object(Instance, [instantiates(Class)], [], Clauses).
:- end_object.
:- object(refasModel, instantiates(metaclass)).

@pmoura
Copy link
Contributor

pmoura commented Jan 9, 2020

The warning results from the plug-in compile an open file (refasModel.lgt in your case) Independently from the loader.lgt file. In most cases, this results in "unknown entity" warnings.

A possible solution is to compile individual files with the unknown_entities flag set to silent. Problem is, when opening the loader file, you do want these warnings.

An alternative solution would be to always compile the loader file when any file in the project is opened or changed and saved. This second alternative may require some UI for the user to set the loader file for an open project. Although defaulting to loader.lgt would work in most cases (and thus be a suitable default), named loader files as loader.lgt is just a convention. @arthwang Is there an example of this kind of UI in other VSC language plug-ins? Would it be simple to implement?

@JacquesRobin
Copy link
Author

Also this initial warning, seems to confuse the Linter, as all the following warnings are empty :(

`refasModel.lgt:33: Warning: Reference to unknown object: list

refasModel.lgt:46: Warning:
refasModel.lgt:47: Warning:
refasModel.lgt:48: Warning:
refasModel.lgt:57: Warning:
refasModel.lgt:57: Warning:
refasModel.lgt:57: Warning:
refasModel.lgt:57: Warning:
refasModel.lgt:83: Warning:
refasModel.lgt:90: Warning:
refasModel.lgt:94: Warning:
refasModel.lgt:100: Warning:
refasModel.lgt:100: Warning:
refasModel.lgt:100: Warning:
refasModel.lgt:110: Warning:
refasModel.lgt:116: Warning:
refasModel.lgt:116: Warning:
refasModel.lgt:125: Warning:
refasModel.lgt:131: Warning:
refasModel.lgt:131: Warning:
refasModel.lgt:140: Warning:
refasModel.lgt:146: Warning:
refasModel.lgt:146: Warning:
refasModel.lgt:160: Warning:
refasModel.lgt:164: Warning:
refasModel.lgt:164: Warning:
refasModel.lgt:164: Warning:
refasModel.lgt:174: Warning:
refasModel.lgt:178: Warning:
refasModel.lgt:178: Warning:
refasModel.lgt:178: Warning:
refasModel.lgt:178: Warning:
refasModel.lgt:189: Warning:
refasModel.lgt:193: Warning:
refasModel.lgt:193: Warning:
refasModel.lgt:203: Warning:
`
in the output tab, even though only a single problem is signaled in the problems tab (the unknown object one)

@pmoura
Copy link
Contributor

pmoura commented Jan 10, 2020

The empty warnings are most likely a plug-in parsing issue. You can confirm by loading the file in a terminal. Please reply with the actual warnings so that we can diagnose where the parsing is failing.

@pmoura
Copy link
Contributor

pmoura commented Jan 10, 2020

I can reproduce the empty warnings with the examples/errors/warnings.lgt file. As in your case, with this file, only the first warning is non-empty. But the warnings line numbers are also wrong after the first warning. Moreover, when browsing the file, only the first warning is underlined.

@arthwang Is it possible that a recent VSC update broke the plug-in? I don't remember having these issues in the past. I'm also noticing that syntax highlighting is wrong for some operators (e.g. \+ and -->). This also seems to be a new problem.

@JacquesRobin
Copy link
Author

JacquesRobin commented Jan 10, 2020

Here are the warnings I get in the output tab with Logtalk Linter selected:

?- {loader}.
% [ /Users/jacquesrobin/logtalk/library/loops/loopp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/loops/loop.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/loops/loader.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/meta/metap.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/meta/meta.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/meta/loader.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/termp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/term.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/atomic.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/atom.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/callable.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/characterp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/character.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/number.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/float.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/integer.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/natural.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/compound.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/pairs.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/listp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/list.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/list1.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/difflist.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/numberlistp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/numberlist.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/varlistp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/varlist.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/comparingp.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/type.lgt loaded ]
% [ /Users/jacquesrobin/logtalk/library/types/loader.lgt loaded ]
*     Reference to unknown object: gsContext(A,B)
*       while compiling object gsSAS
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 61-77
*     
*     Reference to unknown object: transmitData
*       while compiling object predictFlooding
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 114-121
*     
*     Reference to unknown object: organizeNetwork
*       while compiling object predictFlooding
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 114-121
*     
*     Reference to unknown object: calculateFlowRate
*       while compiling object predictFlooding
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 114-121
*     
*     Reference to unknown object: bluetooth
*       while compiling object transmitData
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 134-139
*     
*     Reference to unknown object: wifi
*       while compiling object transmitData
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 134-139
*     
*     Reference to unknown object: fhTopology
*       while compiling object organizeNetwork
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 152-157
*     
*     Reference to unknown object: spTopology
*       while compiling object organizeNetwork
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 152-157
*     
*     Reference to unknown object: singleNodeProcessing
*       while compiling object calculateFlowRate
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 170-175
*     
*     Reference to unknown object: distributedProcessing
*       while compiling object calculateFlowRate
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 170-175
*     
*     Reference to unknown object: bluetooth
*       while compiling object energyEfficiency
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 192-198
*     
*     Reference to unknown object: wifi
*       while compiling object energyEfficiency
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 192-198
*     
*     Reference to unknown object: singleNodeProcessing
*       while compiling object energyEfficiency
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 192-198
*     
*     Reference to unknown object: bluetooth
*       while compiling object faultTolerance
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 211-218
*     
*     Reference to unknown object: wifi
*       while compiling object faultTolerance
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 211-218
*     
*     Reference to unknown object: fhTopology
*       while compiling object faultTolerance
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 211-218
*     
*     Reference to unknown object: spTopology
*       while compiling object faultTolerance
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 211-218
*     
*     Reference to unknown object: singleNodeProcessing
*       while compiling object predictionAccuracy
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 229-234
*     
*     Reference to unknown object: distributedProcessing
*       while compiling object predictionAccuracy
*       in file /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt between lines 229-234
*     
% [ /Users/jacquesrobin/VariaMos/gridstix/lgt/refasModel.lgt loaded ]
% [ /Users/jacquesrobin/VariaMos/gridstix/lgt/loader.lgt loaded ]
% 19 compilation warnings
true.

?- 

Is there a way to cut and paste code so that the pasted result includes the line numbers?
And also (unrelated) is there a way to selectively load only some logtalk types (e.g., list) and not all of them?

Cheers!

@pmoura
Copy link
Contributor

pmoura commented Jan 11, 2020

Please edit your above reply by writing ```logtalk before and ``` (in their own lines) after the terminal output for proper formatting and readability.

Also, is there a public repo with the code?

P.S. The warnings seem to be caused simply by the object definition order in the refasModel.lgt source file. I.e. objects making references to other objects defined later in the same file. The first warning is likely a missing :- use_module(clpfd, [(#=)/3]). directive in the gridStixModel object definition. If you add logtalk_load(tutor(loader))to your loader.lgt you will get explanations and suggestions for most warnings and errors.

@JacquesRobin
Copy link
Author

Done. See above.

@pmoura
Copy link
Contributor

pmoura commented Jan 11, 2020

Thanks. Let's restrict this discussion here to the plug-in warnings parsing issue. For general questions on Logtalk, please use its forums (http://forums.logtalk.org/) or chat room (https://gitter.im/LogtalkDotOrg/logtalk3).

@JacquesRobin
Copy link
Author

Also, is there a public repo with the code?

Not yet, but I can invite you as team member of our the Azure Devops repo if you wish.

P.S. The warnings seem to be caused simply by the object definition order in the refasModel.lgt source file. I.e. objects making references to other objects defined later in the same file.

Indeed ! By reordering the object definitions bottom-up the dependency hierarchy instead of top-down, all the loading warnings are gone.

But the VSC plug-in still underlines the first :- use_module or :-uses directive in the file and gives a reference to unknown (module or object) warning followed by a bunch of empty warnings in the output tab, while only listing the first warning in the problems tab.

If you add logtalk_load(tutor(loader))to your loader.lgt you will get explanations and suggestions for most warnings and errors.

Great tip, thanks!

@pmoura
Copy link
Contributor

pmoura commented Jan 14, 2020

Also, is there a public repo with the code?

Not yet, but I can invite you as team member of our the Azure Devops repo if you wish.

@JacquesRobin Sure. It will be interesting to learn more about your Logtalk application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants