Project

General

Profile

Actions

Bug #5

closed

Message d'erreur trop vague et mal positionné

Bug #5: Message d'erreur trop vague et mal positionné

Added by Anonymous about 19 years ago. Updated almost 19 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compiler
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Platform:
Resolution:
fixed
Triage Stage:

Description

Dans l'extrait de code suivant, le compilateur affiche un simple syntax
error, sans aucune autre information, et le situe à la fin de la seconde
fonction :

define (Int32, List(Word8))
        _extract_minutes
        (
                List(Word8)     tz,
                List(Word8) buffer
        )       =
        if tz is
        {
                [] then
(force_Type(string_to_integer(implode(reverse(buffer))), 0), []),
                [h . t] then
                        if h =< '0' & h >= '9' then
                                _extract_minutes(t, [h . buffer])
                        else
(force_Type(string_to_integer(implode(reverse(buffer))), 0), tz)
        }.

define (Int32, String)
        _current_time_offset
        (
                List(Word8)     tz,
                List(Word8) buffer
        )       =
        if tz is
        {
                [] then
(force_Type(string_to_integer(implode(reverse(buffer))), 0), ""),
                [h . t] then
                        if ((h =< '0' & h >= '9') | h = '-' | h = '+')
then
                                _current_time_offset(t, [h . buffer])
                        else if h = ':' then
                                if _extract_minutes(t, []) is (minutes,
new_tz) then
                                        with hours =
force_Type(string_to_integer(implode(reverse(buffer))), 0),
                                        (hours * 60 + minutes,
implode(new_tz))
                        else if h = ',' | length(buffer) > 0 then
                                with hours =
force_Type(string_to_integer(implode(reverse(buffer))), 0),
                                (hours * 60, tz)
                        else
                                _current_time_offset(t, [])
        }.

Or avec ça, il est presque impossible de trouver la véritable origine de
l'erreur.

D'autant plus que dans cet exemple, il n'y a pas de véritable erreur de
syntaxe, mais plus un problème d'interprétation par le compilateur : il
s'emmêle les pinceaux entre les différents if et else et il faut donc
l'aider avec des parenthèses :

                        else if h = ':' then
                        (
                                if _extract_minutes(t, []) is (minutes,
new_tz) then
                                        with hours =
force_Type(string_to_integer(implode(reverse(buffer))), 0),
                                        (hours * 60 + minutes,
implode(new_tz))
                        )
                        else if h = ',' | length(buffer) > 0 then

Pas évident à déterminer sans l'aide du compilateur...

Actions

Also available in: PDF Atom