google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.56k stars 106 forks source link

Build problem on mac with index.js #1346

Closed duvenaud closed 2 months ago

duvenaud commented 2 months ago

I started a clean install of dex on Mac, was able to install all the dependencies, and I think everything actually compiles and runs now. However, the web interface seems to be broken.

During make install, I get this warning:

[57 of 61] Compiling TopLevel
[58 of 61] Compiling Live.Eval
[59 of 61] Compiling RenderHtml
[60 of 61] Compiling Live.Web
[61 of 61] Compiling Export
ld: warning: -single_module is obsolete
ld: warning: ignoring duplicate libraries: '-lc++', '-lz'
Preprocessing executable 'dex' for dex-0.1.0.0..
Building executable 'dex' for dex-0.1.0.0..
[1 of 1] Compiling Main
Linking .stack-work-opt/dist/x86_64-osx/ghc-8.10.7/build/dex/dex ...
ld: warning: ignoring duplicate libraries: '-lc++', '-lm', '-lz'

Warning: File listed in dex.cabal file does not exist: ./static/index.js
dex> copy/register
Cabal-simple_6HauvNHV_3.2.1.0_ghc-8.10.7: filepath wildcard 'static/index.js'
does not match any files.

I realize that at some point tsc is supposed to be called to turn index.ts into index.js. However, the corresponding rule maybe isn't firing? When I run what appears to be the corresponding line in the makefile, I get:

tsc --strict --lib es2015,dom static/index.ts
static/index.ts:21:6 - error TS2300: Duplicate identifier 'HighlightType'.

21 type HighlightType = "HighlightGroup" |  "HighlightLeaf" | "HighlightError" | "HighlightScope"
        ~~~~~~~~~~~~~

  ../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:28303:6
    28303 type HighlightType = "grammar-error" | "highlight" | "spelling-error";
               ~~~~~~~~~~~~~
    'HighlightType' was also declared here.

static/index.ts:23:6 - error TS2300: Duplicate identifier 'Highlight'.

23 type Highlight    = [SrcId, HighlightType]
        ~~~~~~~~~

  ../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:13541:11
    13541 interface Highlight {
                    ~~~~~~~~~
    'Highlight' was also declared here.
  ../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:13549:13
    13549 declare var Highlight: {
                      ~~~~~~~~~
    and here.

static/index.ts:254:52 - error TS2345: Argument of type '"HighlightError"' is not assignable to parameter of type 'HighlightType'.

254                     highlightTreeNode(false, node, "HighlightError")}
                                                       ~~~~~~~~~~~~~~~~

static/index.ts:308:15 - error TS2461: Type 'Highlight' is not an array type.

308         const [sid, ty] = h
                  ~~~~~~~~~

static/index.ts:317:51 - error TS2366: Function lacks ending return statement and return type does not include 'undefined'.

317 function computeHighlightClass(h:HighlightType) : string {
                                                      ~~~~~~

static/index.ts:319:14 - error TS2678: Type '"HighlightGroup"' is not comparable to type 'HighlightType'.

319         case "HighlightGroup":
                 ~~~~~~~~~~~~~~~~

static/index.ts:321:14 - error TS2678: Type '"HighlightLeaf"' is not comparable to type 'HighlightType'.

321         case "HighlightLeaf":
                 ~~~~~~~~~~~~~~~

static/index.ts:323:14 - error TS2678: Type '"HighlightError"' is not comparable to type 'HighlightType'.

323         case "HighlightError":
                 ~~~~~~~~~~~~~~~~

static/index.ts:325:14 - error TS2678: Type '"HighlightScope"' is not comparable to type 'HighlightType'.

325         case "HighlightScope":
                 ~~~~~~~~~~~~~~~~

static/index.ts:327:14 - error TS2678: Type '"HighlightBinder"' is not comparable to type 'HighlightType'.

327         case "HighlightBinder":
                 ~~~~~~~~~~~~~~~~~

static/index.ts:329:14 - error TS2678: Type '"HighlightOcc"' is not comparable to type 'HighlightType'.

329         case "HighlightOcc":
                 ~~~~~~~~~~~~~~

../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:13541:11 - error TS2300: Duplicate identifier 'Highlight'.

13541 interface Highlight {
                ~~~~~~~~~

  static/index.ts:23:6
    23 type Highlight    = [SrcId, HighlightType]
            ~~~~~~~~~
    'Highlight' was also declared here.

../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:13549:13 - error TS2300: Duplicate identifier 'Highlight'.

13549 declare var Highlight: {
                  ~~~~~~~~~

  static/index.ts:23:6
    23 type Highlight    = [SrcId, HighlightType]
            ~~~~~~~~~
    'Highlight' was also declared here.

../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:28303:6 - error TS2300: Duplicate identifier 'HighlightType'.

28303 type HighlightType = "grammar-error" | "highlight" | "spelling-error";
           ~~~~~~~~~~~~~

  static/index.ts:21:6
    21 type HighlightType = "HighlightGroup" |  "HighlightLeaf" | "HighlightError" | "HighlightScope"
            ~~~~~~~~~~~~~
    'HighlightType' was also declared here.

Found 14 errors in 2 files.

Errors  Files
    11  static/index.ts:21
     3  ../../../../../usr/local/Cellar/typescript/5.4.5/libexec/lib/node_modules/typescript/lib/lib.dom.d.ts:13541

Is this a version error with Typescript?

Also, there was another compiler error that I overcame by editing things locally, which was that dexrt.cpp uses sprintf but clang on Mac now considers this decprecated.

duvenaud commented 2 months ago

Haha, I just ran make install again and it worked and I don't know why. I waited months to file an issue because I assumed i was something on my end, and the very next command I ran after filing this issue made it work.