WhatsApp / eqwalizer

A type-checker for Erlang
Apache License 2.0
513 stars 28 forks source link

Crash on filename or filelib #39

Closed egobrain closed 1 year ago

egobrain commented 1 year ago

Hello. I'm trying to check newly create project using

rebar3 new app eq_test

elp eqwalize-all completes successfully

but if i add a single line, that uses filename or filelib module

-module(eq_test_app).

-behaviour(application).

-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
    _ = filelib:is_file("test.txt"), %% <-- this line
    eq_test_sup:start_link().

stop(_State) ->
    ok.

it crashes with the following error:

 $ RUST_BACKTRACE=1 elp eqwalize-all
⠂ Loading rebar3 build_info
  Loading rebar3 build_info
  Loading applications      ████████████████████ 1/1
  Seeding database
  Compiling dependencies
  eqWAlizing                ██████████░░░░░░░░░░ 1/2  eq_test_app                                                                                                                                                                                              Exception in thread "main" java.lang.IllegalStateException: Expand phase should validate that all remoteIds point to modules that exist, but found eqwalizer:dynamic/0
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.$anonfun$getTypeDeclBody$1(Contractivity.scala:117)
    at scala.Option.getOrElse(Option.scala:201)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.getTypeDeclBody(Contractivity.scala:116)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.isFoldable(Contractivity.scala:88)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.isFoldable(Contractivity.scala:81)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.$anonfun$isFoldable$8(Contractivity.scala:83)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.$anonfun$isFoldable$8$adapted(Contractivity.scala:83)
    at scala.collection.immutable.List.forall(List.scala:386)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.isFoldable(Contractivity.scala:83)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.isContractive(Contractivity.scala:58)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.addTypeDecl(Contractivity.scala:36)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.$anonfun$checkStub$1(Contractivity.scala:22)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.$anonfun$checkStub$1$adapted(Contractivity.scala:22)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
    at com.whatsapp.eqwalizer.ast.stub.Contractivity.checkStub(Contractivity.scala:22)
    at com.whatsapp.eqwalizer.ast.stub.Db$.$anonfun$getContractiveModuleStub$1(Db.scala:167)
    at scala.Option.map(Option.scala:242)
    at com.whatsapp.eqwalizer.ast.stub.Db$.getContractiveModuleStub(Db.scala:167)
    at com.whatsapp.eqwalizer.ast.stub.Db$.getValidatedModuleStub(Db.scala:176)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.isValid(TransValid.scala:143)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.collectInvalidReferences(TransValid.scala:180)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.$anonfun$collectInvalidReferences$3(TransValid.scala:194)
    at scala.collection.immutable.List.flatMap(List.scala:293)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.collectInvalidReferences(TransValid.scala:194)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.$anonfun$collectInvalidReferences$3(TransValid.scala:194)
    at scala.collection.immutable.List.flatMap(List.scala:293)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.collectInvalidReferences(TransValid.scala:194)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.addSpec(TransValid.scala:86)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.$anonfun$checkStub$5(TransValid.scala:35)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.$anonfun$checkStub$5$adapted(TransValid.scala:35)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
    at com.whatsapp.eqwalizer.ast.stub.TransValid.checkStub(TransValid.scala:35)
    at com.whatsapp.eqwalizer.ast.stub.Db$.$anonfun$getModuleStub$1(Db.scala:187)
    at scala.Option.map(Option.scala:242)
    at com.whatsapp.eqwalizer.ast.stub.Db$.getModuleStub(Db.scala:187)
    at com.whatsapp.eqwalizer.ast.stub.DbApi$.getType(DbApi.scala:58)
    at com.whatsapp.eqwalizer.tc.Util.getTypeDeclBody(Util.scala:102)
    at com.whatsapp.eqwalizer.tc.Subtype.subTypePol(Subtype.scala:66)
    at com.whatsapp.eqwalizer.tc.Subtype.subTypePol(Subtype.scala:67)
    at com.whatsapp.eqwalizer.tc.Subtype.$anonfun$subTypePol$4(Subtype.scala:78)
    at com.whatsapp.eqwalizer.tc.Subtype.$anonfun$subTypePol$4$adapted(Subtype.scala:78)
    at scala.collection.immutable.Set$Set2.exists(Set.scala:204)
    at com.whatsapp.eqwalizer.tc.Subtype.subTypePol(Subtype.scala:78)
    at com.whatsapp.eqwalizer.tc.Subtype.subTypePol(Subtype.scala:64)
    at com.whatsapp.eqwalizer.tc.Subtype.subType(Subtype.scala:33)
    at com.whatsapp.eqwalizer.tc.ElabApply.checkArg(ElabApply.scala:135)
    at com.whatsapp.eqwalizer.tc.ElabApply.$anonfun$elabApply$4(ElabApply.scala:126)
    at com.whatsapp.eqwalizer.tc.ElabApply.$anonfun$elabApply$4$adapted(ElabApply.scala:126)
    at scala.collection.immutable.List.foreach(List.scala:333)
    at com.whatsapp.eqwalizer.tc.ElabApply.elabApply(ElabApply.scala:126)
    at com.whatsapp.eqwalizer.tc.Elab.elabExpr(Elab.scala:187)
    at com.whatsapp.eqwalizer.tc.Elab.elabExpr(Elab.scala:273)
    at com.whatsapp.eqwalizer.tc.Check.$anonfun$checkBody$1(Check.scala:55)
    at com.whatsapp.eqwalizer.tc.Check.$anonfun$checkBody$1$adapted(Check.scala:54)
    at scala.collection.immutable.List.foreach(List.scala:333)
    at com.whatsapp.eqwalizer.tc.Check.checkBody(Check.scala:54)
    at com.whatsapp.eqwalizer.tc.Check.checkClause(Check.scala:74)
    at com.whatsapp.eqwalizer.tc.Check.$anonfun$checkFun$1(Check.scala:38)
    at scala.collection.LazyZip2$$anon$1$$anon$2.next(LazyZipOps.scala:42)
    at scala.collection.immutable.List.prependedAll(List.scala:153)
    at scala.collection.immutable.List$.from(List.scala:684)
    at scala.collection.immutable.List$.from(List.scala:681)
    at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:112)
    at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:109)
    at scala.collection.LazyZip2.map(LazyZipOps.scala:37)
    at com.whatsapp.eqwalizer.tc.Check.checkFun(Check.scala:38)
    at com.whatsapp.eqwalizer.Pipeline$.tolerantCheckFun(Pipeline.scala:111)
    at com.whatsapp.eqwalizer.Pipeline$.checkFun(Pipeline.scala:91)
    at com.whatsapp.eqwalizer.Pipeline$.$anonfun$checkForms$1(Pipeline.scala:52)
    at scala.collection.immutable.List.foreach(List.scala:333)
    at com.whatsapp.eqwalizer.Pipeline$.checkForms(Pipeline.scala:35)
    at com.whatsapp.eqwalizer.util.ELPDiagnostics$.getDiagnostics(ELPDiagnostics.scala:49)
    at com.whatsapp.eqwalizer.util.ELPDiagnostics$.$anonfun$getDiagnosticsIpc$2(ELPDiagnostics.scala:36)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
    at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:896)
    at com.whatsapp.eqwalizer.util.ELPDiagnostics$.getDiagnosticsIpc(ELPDiagnostics.scala:34)
    at com.whatsapp.eqwalizer.Main$.ipc(Main.scala:63)
    at com.whatsapp.eqwalizer.Main$.main(Main.scala:29)
    at com.whatsapp.eqwalizer.Main.main(Main.scala)
thread 'main' panicked at 'failed to parse stdout from eqwalizer: Error("EOF while parsing a value", line: 1, column: 0)', crates/eqwalizer/src/ipc.rs:91:40
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <elp_ide_db::RootDatabase as elp_ide_db::eqwalizer::EqwalizerLoader>::typecheck
   4: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   5: <DB as elp_ide_db::eqwalizer::EqwalizerDatabase>::eqwalizer_diagnostics::__shim
   6: elp::eqwalizer_cli::eqwalize
   7: elp::try_main
   8: elp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

erlang 25.3.2.4 macOs 13.5 elp v0.17.16

VLanvin commented 1 year ago

Have you added eqwalizer_support as a dep of your rebar project? (see https://github.com/WhatsApp/eqwalizer#using-it-with-rebar3-projects)

eqwalizer:dynamic, as well as several other types are provided by eqwalizer_support.

egobrain commented 1 year ago

🤦 , thanks. Now it works!