Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3 code compilation issues #361

Open
bblfish opened this issue Sep 28, 2021 · 4 comments
Open

Scala 3 code compilation issues #361

bblfish opened this issue Sep 28, 2021 · 4 comments

Comments

@bblfish
Copy link

bblfish commented Sep 28, 2021

Hi,

When I compile the generated code for rdflib.js in Scala3 in strict mode, I get the following warnings:

  • a number of warnings on classes not being declared open
  • a number of errors on using the x: _* syntax rather than the * syntax
  • a number of errors because Any is set to Nul, e.g.
 val __obj = js.Dynamic.literal(
     arrayBuffer = js.Any.fromFunction0(arrayBuffer), 
     blob = js.Any.fromFunction0(blob), 
     bodyUsed = bodyUsed.asInstanceOf[js.Any], 
     formData = js.Any.fromFunction0(formData), 
     json = js.Any.fromFunction0(json), 
     text = js.Any.fromFunction0(text), 
     body = null) // <-- here

Those will be easy to fix, but perhaps there is a flag that I can set to get it right out of the box? I fixed them in this commit by hand. Now I just have to test the code with a few examples...

Originally posted by @bblfish in #359

@oyvindberg
Copy link
Collaborator

Hey there, and thanks for the report!

I haven't tested the converter with anything newer than scala 3.0.2, and I haven't set a strict flag when using it. Does this mean you specified some scalacOptions yourself?

These things should all be easy enough to fix I think. Unfortunately I have less time than normal these days, so it'll be some time before I get to it

@bblfish
Copy link
Author

bblfish commented Sep 28, 2021

yes, I set quite a lot of scalacOptions, as I am trying to make sure the library I am building is using the right structures for Scala3.

Currently I have

val scala3jsOptions =  Seq(
   // "-classpath", "foo:bar:...",         // Add to the classpath.
   //"-encoding", "utf-8",                // Specify character encoding used by source files.
   "-deprecation",                      // Emit warning and location for usages of deprecated APIs.
   "-unchecked",                        // Enable additional warnings where generated code depends on assumptions.
   "-feature",                          // Emit warning and location for usages of features that should be imported explicitly.
   //"-explain",                          // Explain errors in more detail.
   //"-explain-types",                    // Explain type errors in more detail.
   "-indent",                           // Together with -rewrite, remove {...} syntax when possible due to significant indentation.
   // "-no-indent",                        // Require classical {...} syntax, indentation is not significant.
   "-new-syntax",                       // Require `then` and `do` in control expressions.
   // "-old-syntax",                       // Require `(...)` around conditions.
   // "-language:Scala2",                  // Compile Scala 2 code, highlight what needs updating
   //"-language:strictEquality",          // Require +derives Eql+ for using == or != comparisons
   // "-rewrite",                          // Attempt to fix code automatically. Use with -indent and ...-migration.
   // "-scalajs",                          // Compile in Scala.js mode (requires scalajs-library.jar on the classpath).
   "-source:future",                       // Choices: future and future-migration. I use this to force future deprecation warnings, etc.
   // "-Xfatal-warnings",                  // Fail on warnings, not just errors
   // "-Xmigration",                       // Warn about constructs whose behavior may have changed since version.
   // "-Ysafe-init",                       // Warn on field access before initialization
   "-Yexplicit-nulls"                  // For explicit nulls behavior.
)

Not a big deal, as I fixed it by hand.

@oyvindberg
Copy link
Collaborator

I'd be happy to support future source and explicit nulls at least, it is the best way forward

oyvindberg added a commit that referenced this issue Sep 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…a 3 (towards #361)
@oyvindberg
Copy link
Collaborator

Implemented -source:future in #364, while -Yexplicit-nulls is a bit more work. At the very least it should be done on top of #363 since there seems to be some friction with js.Any (which needs to be used for js.Dynamic)

oyvindberg added a commit that referenced this issue Oct 2, 2021
Implement necessary changes to compile with `-source:future` for scala 3 (towards #361)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants