[ambiguous occurrence bug?]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[ambiguous occurrence bug?]

GHC - devs mailing list
Sorry in advance if I should be posting questions of this kind elsewhere (please tell me if so!).

Consider this two file program:
```
module T where
main = undefined

module Main where
import T
main = putStrLn "Hello world!"
```

Both 8.4.3 and 8.6.3 agree:
```
Main.hs:1:1: error:
    Ambiguous occurrence ‘main’
    It could refer to either ‘T.main’,
                             imported from ‘T’ at Main.hs:2:1-8
                             (and originally defined at Main.hs:2:1-4)
                          or ‘Main.main’, defined at Main.hs:5:1
```

Is this expected behavior? Does it not contradict "If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported" (https://www.haskell.org/onlinereport/haskell2010/haskellch5.html)? If the latter, is this a bug? What am I missing?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

Brandon Allbery
No contradiction: "not those that are imported" means a module which imports names does not automatically re-export those names to other modules that import it. So T does indeed export "main", which is imported unqualified by Main and thereby causes an ambiguous occurrence. But if T had imported "main" from a third module, it would not be exported for Main to import unless the export from T was explicit.

On Sun, Mar 17, 2019 at 1:50 PM Shayne Fletcher via ghc-devs <[hidden email]> wrote:
Sorry in advance if I should be posting questions of this kind elsewhere (please tell me if so!).

Consider this two file program:
```
module T where
main = undefined

module Main where
import T
main = putStrLn "Hello world!"
```

Both 8.4.3 and 8.6.3 agree:
```
Main.hs:1:1: error:
    Ambiguous occurrence ‘main’
    It could refer to either ‘T.main’,
                             imported from ‘T’ at Main.hs:2:1-8
                             (and originally defined at Main.hs:2:1-4)
                          or ‘Main.main’, defined at Main.hs:5:1
```

Is this expected behavior? Does it not contradict "If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported" (https://www.haskell.org/onlinereport/haskell2010/haskellch5.html)? If the latter, is this a bug? What am I missing?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message._______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


--
brandon s allbery kf8nh

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

GHC - devs mailing list
Hi Brandon,

On Sun, Mar 17, 2019 at 2:09 PM Brandon Allbery <[hidden email]> wrote:
No contradiction: "not those that are imported" means a module which imports names does not automatically re-export those names to other modules that import it. So T does indeed export "main", which is imported unqualified by Main

No argument with anything said there.
 
and thereby causes an ambiguous occurrence.

This I don't get. I presume the ambiguous occurrence is due to the question what `main` is `Main.hs` exporting (or in this case is the "entry-point" for the program)? My reading of the above is that only the local `main` can be exported  (or again, in this case, "considered" for the "entry-point") so where is the ambiguity?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

Brandon Allbery
Hm. You're probably right that it should only consider the locally defined one, but I can see why it would do this and wonder if there's even a good way to constrain that check currently.

On Sun, Mar 17, 2019 at 2:16 PM Shayne Fletcher <[hidden email]> wrote:
Hi Brandon,

On Sun, Mar 17, 2019 at 2:09 PM Brandon Allbery <[hidden email]> wrote:
No contradiction: "not those that are imported" means a module which imports names does not automatically re-export those names to other modules that import it. So T does indeed export "main", which is imported unqualified by Main

No argument with anything said there.
 
and thereby causes an ambiguous occurrence.

This I don't get. I presume the ambiguous occurrence is due to the question what `main` is `Main.hs` exporting (or in this case is the "entry-point" for the program)? My reading of the above is that only the local `main` can be exported  (or again, in this case, "considered" for the "entry-point") so where is the ambiguity?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.


--
brandon s allbery kf8nh

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

GHC - devs mailing list

On Sun, Mar 17, 2019 at 2:23 PM Brandon Allbery <[hidden email]> wrote:
Hm. You're probably right that it should only consider the locally defined one,

Cool.
 
but I can see why it would do this
Can you elaborate? Perhaps,
 
and wonder if there's even a good way to constrain that check currently.


indicates that you can see why it might be so based on knowledge of the implementation?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

Brandon Allbery
I'm guessing, but I suspect currently the only way to look up a symbol either requires explicit qualification of the symbol name or that the symbol be part of a class or instance declaration that implicitly qualifies method and associated type names. So for the implicit export list to retrieve the local symbol definition, it would have to explicitly request the local one instead of simply passing the name. (But getting the local names, without their definitions, wouldn't hit this. Maybe that should return explicitly qualified names, but I could see that causing problems with ghci; consider ":browse". And that it already handles qualification somewhat oddly because multiple modules can be in scope; "import" doesn't mean quite the same thing in ghci as in ghc, and can't without making its interactive use rather more painful when multiple modules are in scope.)

On Sun, Mar 17, 2019 at 2:30 PM Shayne Fletcher <[hidden email]> wrote:

On Sun, Mar 17, 2019 at 2:23 PM Brandon Allbery <[hidden email]> wrote:
Hm. You're probably right that it should only consider the locally defined one,

Cool.
 
but I can see why it would do this
Can you elaborate? Perhaps,
 
and wonder if there's even a good way to constrain that check currently.


indicates that you can see why it might be so based on knowledge of the implementation?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.


--
brandon s allbery kf8nh

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

Richard Eisenberg-5
In reply to this post by GHC - devs mailing list
This looks like a bug to me. Post at https://gitlab.haskell.org/ghc/ghc/issues/

Thanks!
Richard

On Mar 17, 2019, at 1:50 PM, Shayne Fletcher via ghc-devs <[hidden email]> wrote:

Sorry in advance if I should be posting questions of this kind elsewhere (please tell me if so!).

Consider this two file program:
```
module T where
main = undefined

module Main where
import T
main = putStrLn "Hello world!"
```

Both 8.4.3 and 8.6.3 agree:
```
Main.hs:1:1: error:
    Ambiguous occurrence ‘main’
    It could refer to either ‘T.main’,
                             imported from ‘T’ at Main.hs:2:1-8
                             (and originally defined at Main.hs:2:1-4)
                          or ‘Main.main’, defined at Main.hs:5:1
```

Is this expected behavior? Does it not contradict "If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported" (https://www.haskell.org/onlinereport/haskell2010/haskellch5.html)? If the latter, is this a bug? What am I missing?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message._______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

Ben Gamari-2
In reply to this post by GHC - devs mailing list
Shayne Fletcher via ghc-devs <[hidden email]> writes:

> Sorry in advance if I should be posting questions of this kind elsewhere
> (please tell me if so!).
>
> Consider this two file program:
> ```
> module T where
> main = undefined
>
> module Main where
> import T
> main = putStrLn "Hello world!"
> ```
>
> Both 8.4.3 and 8.6.3 agree:
> ```
> Main.hs:1:1: error:
>     Ambiguous occurrence ‘main’
>     It could refer to either ‘T.main’,
>                              imported from ‘T’ at Main.hs:2:1-8
>                              (and originally defined at Main.hs:2:1-4)
>                           or ‘Main.main’, defined at Main.hs:5:1
> ```
>
> Is this expected behavior? Does it not contradict "If the export list is
> omitted, all values, types and classes defined in the module are exported,
> but not those that are imported" (
> https://www.haskell.org/onlinereport/haskell2010/haskellch5.html)? If the
> latter, is this a bug? What am I missing?
>
The language you cite from the report makes it sound as though this is a
bug. Can you open a ticket?

Cheers,

- Ben

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ambiguous occurrence bug?]

GHC - devs mailing list
On Mon, Mar 18, 2019 at 9:30 PM Ben Gamari <[hidden email]> wrote:
Shayne Fletcher via ghc-devs <[hidden email]> writes:

> Consider this two file program:
> ```
> module T where
> main = undefined
>
> module Main where
> import T
> main = putStrLn "Hello world!"
> ```
>
> Both 8.4.3 and 8.6.3 agree:
> ```
> Main.hs:1:1: error:
>     Ambiguous occurrence ‘main’
>     It could refer to either ‘T.main’,
>                              imported from ‘T’ at Main.hs:2:1-8
>                              (and originally defined at Main.hs:2:1-4)
>                           or ‘Main.main’, defined at Main.hs:5:1
> ```
>
> Is this expected behavior? Does it not contradict "If the export list is
> omitted, all values, types and classes defined in the module are exported,
> but not those that are imported" (
> https://www.haskell.org/onlinereport/haskell2010/haskellch5.html)? If the
> latter, is this a bug? What am I missing?
>
The language you cite from the report makes it sound as though this is a
bug. Can you open a ticket?

--
Shayne Fletcher
Language Engineer
c: +1 917 699 7763
e: [hidden email]
Digital Asset Holdings, LLC
4 World Trade Center                                                        150 Greenwich Street, 47th Floor         
New York, NY 10007, USA
digitalasset.com


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.digitalasset.com/emaildisclaimer.html. If you are not the intended recipient, please delete this message.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs