haskell / happy

The Happy parser generator for Haskell
Other
279 stars 84 forks source link

`happy-2.0.2` regresses `language-python-0.5.8` #316

Open bgamari opened 2 hours ago

bgamari commented 2 hours ago
dist/build/Language/Python/Version2/Parser/Parser.hs:7426:4: error: [GHC-83865]
    • Couldn't match type ‘Happy_GHC_Exts.Int32#’
                     with ‘Happy_GHC_Exts.Int#’
      Expected: Happy_Int
        Actual: Happy_GHC_Exts.Int32#
    • In the expression: Happy_GHC_Exts.indexInt32OffAddr# arr off
      In an equation for ‘happyIndexOffAddr’:
          happyIndexOffAddr (HappyA# arr) off
            = (Happy_GHC_Exts.indexInt32OffAddr# arr off)
     |
7426 |   (Happy_GHC_Exts.indexInt32OffAddr# arr off)
     |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Using GHC 9.6.5.

Ericson2314 commented 2 hours ago

Huh that looks like an older bug that happened when the GHC unboxed number one was changing. I didn't think anything happened relative this since the last 1.x release.

bgamari commented 2 hours ago

I can confirm that the same project builds with happy-1.20.1.1.

Ericson2314 commented 2 hours ago

@bgamari Can you diff the generated parsers?

bgamari commented 1 hour ago

@Ericson2314 see https://gist.github.com/bgamari/87c10deca02c86460f0935f511cae768.

sgraf812 commented 1 hour ago

Very strange. It must be this line from the template: https://github.com/haskell/happy/blob/1f92300fe148d46235707f069b639016c0e635d7/lib/data/HappyTemplate.hs#L127

But we test this code path quite extensively on GHC 9.6 and lower. Is there anything special about the architecture? 32 bit?

(The diff appears to be incomplete, btw. Not that it matters.)

Bodigrim commented 18 minutes ago

That's because of https://github.com/bjpop/language-python/blob/8e0a43ddfd1b9e22d104ece01333706d0fe71e04/language-python/src/Language/Python/Version2/Parser/Parser.y#L4-L5

#undef __GLASGOW_HASKELL__
#define __GLASGOW_HASKELL__ 709
Bodigrim commented 14 minutes ago

I've seen this ugly hack used in the wild more than once to work around https://github.com/haskell/happy/issues/109. For this particular instance see discussion at https://github.com/bjpop/language-python/issues/41.

Instead of #if __GLASGOW_HASKELL__ >= 901 we can check #if MIN_VERSION_base(4,15,0), which is equivalent, but immune to #undef __GLASGOW_HASKELL__.