gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improved error messages soon to be added to the git master


From: Gaius Mulley
Subject: improved error messages soon to be added to the git master
Date: Fri, 29 May 2020 01:30:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hello,

I thought I'd post some examples of the new error messages which will be
added to the git master once all the regressions pass.

There is still a little tidying up to do and also it will be extended to
incorporate procedure functions.  I'll also git branch the master for
gcc-10 in the next few days - so the changes below will go into the git
master (for gcc-11) as there are many changes.

Anyway here is the demo :-)


for i in expression*.mod unary.mod ; do cat $i; echo gm2 -g -c -fiso $i;
gm2 -g -c -fiso $i; done


(* Copyright (C) 2020 Free Software Foundation, Inc. *)
(* This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with gm2; see the file COPYING.  If not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)

MODULE expression2 ;

VAR
   i   : CHAR ;
   j, k: CARDINAL ;
BEGIN
   i := j + k
END expression2.

$ gm2 -g -c -fiso expression2.mod
expression2.mod:24:6: error: assignment of ‘i’ with expression
   24 |    i := j + k
      |      ^~
expression2.mod:24:6: error: ‘CHAR’ and ‘CARDINAL’ are incompatible in this 
context
expression2.mod:24:6: error: assignment check caught mismatch between ‘i’ and 
expression
   24 |    i := j + k
      |      ^~~~~~~~
(* Copyright (C) 2020 Free Software Foundation, Inc. *)
(* This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with gm2; see the file COPYING.  If not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)

MODULE expression3 ;

VAR
   r   : REAL ;
   j, k: CARDINAL ;
BEGIN
   r := 3.14 ;
   k := (j + k) + r ;
   (* another line.  *)
END expression3.

$ gm2 -g -c -fiso expression3.mod
expression3.mod:25:17: error: expression of type ‘CARDINAL’ is incompatible 
with type ‘REAL’
   25 |    k := (j + k) + r ;
      |          ~~~~~~~^~~
expression3.mod:25:17: error: ‘CARDINAL’ and ‘REAL’ are incompatible in this 
context
expression3.mod:25:17: error: expression of type ‘CARDINAL’ is incompatible 
with type ‘REAL’
(* Copyright (C) 2020 Free Software Foundation, Inc. *)
(* This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with gm2; see the file COPYING.  If not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)

MODULE expression4 ;

VAR
   j, k: CARDINAL ;
BEGIN
   k := (j + k) + 3.14 ;
   (* another line.  *)
END expression4.

$ gm2 -g -c -fiso expression4.mod
expression4.mod:23:17: error: expression of type ‘CARDINAL’ is incompatible 
with type ‘Modula-2 base R’
   23 |    k := (j + k) + 3.14 ;
      |          ~~~~~~~^~~~~~
expression4.mod:23:17: error: ‘CARDINAL’ and the RType are incompatible in this 
context
expression4.mod:23:17: error: expression of type ‘CARDINAL’ is incompatible 
with type ‘Modula-2 base R’
(* Copyright (C) 2020 Free Software Foundation, Inc. *)
(* This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with gm2; see the file COPYING.  If not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)

MODULE expression ;

VAR
   k   : CHAR ;
   i, j: CARDINAL ;
BEGIN
   i := j + k
END expression.

$ gm2 -g -c -fiso expression.mod
expression.mod:24:11: error: expression of type ‘CARDINAL’ is incompatible with 
type ‘CHAR’
   24 |    i := j + k
      |         ~~^~~
expression.mod:24:11: error: ‘CARDINAL’ and ‘CHAR’ are incompatible in this 
context
expression.mod:24:11: error: expression of type ‘CARDINAL’ is incompatible with 
type ‘CHAR’
(* Copyright (C) 2020 Free Software Foundation, Inc. *)
(* This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with gm2; see the file COPYING.  If not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)

MODULE unary ;

VAR
   c: CHAR ;
   i: CARDINAL ;
BEGIN
   i := - c
END unary.

$ gm2 -g -c -fiso unary.mod
unary.mod:24:6: error: assignment of ‘i’ with expression
   24 |    i := - c
      |      ^~
unary.mod:24:6: error: ‘CARDINAL’ and ‘CHAR’ are incompatible in this context
unary.mod:24:6: error: assignment check caught mismatch between ‘i’ and 
expression
   24 |    i := - c
      |      ^~~~~~

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]