Type checking questions

Thorkil Naur naur at post11.tele.dk
Wed Nov 2 21:07:05 GMT 2011


Hello Benedikt,

I have started to play with language-c and noted the following:

1.  In the language-c-0.4.2 package that I downloaded from hackage, the
    following files, mentioned in the README, are not included:

      src/README
      examples
      test(/harness)

    The files are present in the darcs repository, so this is not a
    pressing issue.

2.  The type checker disagrees with gcc. For example:

      $ echo "int u(){} int u;" > t1.c
      $ ./TypeCheck t1.c 
      t1.c: success
      $ gcc -c t1.c 
      t1.c:1: error: ‘u’ redeclared as different kind of symbol
      t1.c:1: note: previous definition of ‘u’ was here
      $

    Apparently, the failure to detect this problem is in the
    (presumably) missing details of

      checkCompatibleTypes :: Type -> Type -> Either TypeMismatch ()
      checkCompatibleTypes _ _ = Right ()

    in Language/C/Analysis/TravMonad.hs.

3.  To be able to produce a TypeMismatch, checkCompatibleTypes would
    seem to need a couple of NodeInfo's, which I don't understand how
    it could manage to get hold of.

4.  And, if I just uses the useless undefNode to report TypeMismatch'es
    in checkCompatibleTypes, I get a problem when reporting them:

      *** Exception: No match in record selector posFile

    This happens in showErrorInfo in Language/C/Data/Error.hs which is
    not prepared to handle ErrorInfo's with Position's that are
    NoPosition (or one of the other non-Position variants).

I hope that you (and cc: the language-c mailing list) are the right
audience for this and will be able to comment.

Thanks and best regards
Thorkil



More information about the Language-c mailing list