Opened 10 years ago

Last modified 22 months ago

#2147 new bug

unhelpful error message for a misplaced DEPRECATED pragma

Reported by: guest Owned by:
Priority: lowest Milestone:
Component: Compiler (Parser) Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

The error message on a misplaced DEPRECATED pragma is less than helpful. Note that it was the latter of these that bit me.

% cat Main.hs

module Main where

import Foo.Bar

main = return ()

% cat Foo/Bar.hs

{-# DEPRECATED foo "bar" #-}

module Foo.Bar (foo) where

foo = undefined

% ghc -c Foo/Bar.hs

Foo/Bar.hs:4:0: parse error on input `module'

% ghc --make Main.hs

Foo/Bar.hs:1:0: file name does not match module name `Main'

Change History (21)

comment:1 Changed 10 years ago by igloo

difficulty: Unknown
Milestone: 6.8.3

Thanks for the report, we'll take a look.

comment:2 Changed 9 years ago by igloo

Milestone: 6.8.36.10.1

comment:3 Changed 9 years ago by igloo

Description: modified (diff)

comment:4 Changed 9 years ago by igloo

In the HEAD/6.10 we get:

Foo/Bar.hs:1:0:
    File name does not match module name:
    Saw: `Main'
    Expected: `Foo.Bar'

The problem is that when we go to compile Foo.Bar we first want to get its imports, so that we know what else we have to compile first. When we hit the pragma, we think that the module body has started, and do not parse any more, so as far as GHC is concerned this is a module that has no header, and thus defaults to module Main. I'm not sure how we can do better. Perhaps returning the source location at which we decide what the module name is would help?

comment:5 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:7 Changed 9 years ago by igloo

Milestone: 6.10.16.10 branch

comment:8 Changed 9 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:9 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:10 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:11 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:12 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:13 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:14 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:15 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:16 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:17 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:18 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:19 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:20 Changed 2 years ago by thomie

Component: CompilerCompiler (Parser)
Type of failure: None/Unknown

comment:21 Changed 22 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.