misleading error message

5 views
Skip to first unread message

Ralf Hemmecke

unread,
Apr 20, 2023, 6:03:01 AM4/20/23
to fricas-devel
Dear Waldek,

This is about a misleading error message.

When I compile my code with this function

initialize(m: List F): % ==
t: F := first m
per [initialize(t)$AB, sort(smallerGrade?, rest m), empty()]

the compiler spits out the stuff at the end of the mail.
In particular it it marks the error to this.

(|construct| | << | ((|Sel| AB |initialize|) |t|) | >> |

That came to me as a surprise, because the changes to the previous
version did not involve anything connected to iniitalize, but rather
were a renaming of smallerGrade? to less?.

Now I see that the compiler gave a warning:

[4] initialize: smallerGrade? has no value

which should not be a warning, but is the actual cause of the error.
I should also have renamed smallerGrade? to less? in the function cited
above.

Is it worth it that I make a small example program that you can compile
and that demonstrates the above proplem? Or do we just leave the
situation as is? I think, it's a bug, but I have no immediate incentive
to invest time in it, since the compiler messages are anyway usually
pretty hard to decipher.

Ralf


===================================================================

compiling exported initialize : List F -> $
Semantic Errors:
[1] addPair!: f1 is BOTH a variable and a literal
[2] addPair!: f2 is BOTH a variable and a literal

Warnings:
[1] update!: irr has no value
[2] update!: red has no value
[3] update!: cbe has no value
[4] initialize: smallerGrade? has no value

****** comp fails at level 6 with expression: ******
error in function initialize

(SEQ (|:=| (|:| |t| F) (|first| |m|))
(|exit| 1
(|pretend|
(@
(|construct| | << | ((|Sel| AB |initialize|) |t|) | >> |
(|sort| |smallerGrade?| (|rest| |m|)) (|empty|))
(|Record| (|:| |ab| AB) (|:| |cbe| (|List| F))
(|:| |pairs|
(|XHashTable| (|Integer|)
(|List|
(|Record| (|:| |f1| F) (|:| |f2|
F)))))))
$)))
****** level 6 ******
$x:= ((Sel AB initialize) t)
$m:= F
$f:=
((((|t| # #) (|m| # #) (|#| #) (< #) ...) ((|multiplier| # #) (|less?| #))
((|less?| #) (|orderedC?| # #) (C # #) (~= #) ...)))

>> Apparent user error:
NoValueMode
is an unknown mode

Waldek Hebisch

unread,
Apr 21, 2023, 12:43:32 PM4/21/23
to fricas...@googlegroups.com
On Thu, Apr 20, 2023 at 12:02:59PM +0200, Ralf Hemmecke wrote:
> Dear Waldek,
>
> This is about a misleading error message.
>
> When I compile my code with this function
>
> initialize(m: List F): % ==
> t: F := first m
> per [initialize(t)$AB, sort(smallerGrade?, rest m), empty()]
>
> the compiler spits out the stuff at the end of the mail.
> In particular it it marks the error to this.
>
> (|construct| | << | ((|Sel| AB |initialize|) |t|) | >> |
>
> That came to me as a surprise, because the changes to the previous version
> did not involve anything connected to iniitalize, but rather were a renaming
> of smallerGrade? to less?.
>
> Now I see that the compiler gave a warning:
>
> [4] initialize: smallerGrade? has no value
>
> which should not be a warning, but is the actual cause of the error.

Well, "has no value" means that Spad compiler did not see assignment
or initialization of variable. In this specific case it means error
but in general variable may have value assigned and Spad compiler
may miss this. So the message can only be warning. For example,
during algebra build Spad compiler emits 7931 such messages.
Algebra may contain errors, but vast majority of such cases is OK.

> I should also have renamed smallerGrade? to less? in the function cited
> above.
>
> Is it worth it that I make a small example program that you can compile and
> that demonstrates the above proplem?

AFAICS you gave enough info to reproduce the problem.

> Or do we just leave the situation as
> is? I think, it's a bug, but I have no immediate incentive to invest time in
> it, since the compiler messages are anyway usually pretty hard to decipher.

I would not call this "bug". You example is an easy one, but
there are fundamental limitations what Spad-like compiler can
do in such cases. I wonder what Aldor reports for such code?

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages