GithubHelp home page GithubHelp logo

Comments (4)

sjrd avatar sjrd commented on June 10, 2024 1

This is working as designed. The behavior is indeed a consequence of value-based type tests for numeric types. The fact that it behaves like Int instead of Byte/Short is the better trade-off. As mentioned in the issue description, portable behavior is recoverable by converting to Int; if we had chosen the other way around, no workaround would exist for the Int behavior.

from scala-js.

gzm0 avatar gzm0 commented on June 10, 2024

Hrm. I was going to write that this is a direct consequence of "Runtime type tests are based on values" documented here: https://www.scala-js.org/doc/semantics.html

However, one would expect the JVM result in this case. It seems that the relevant code simply only considers ints and longs:

val str = arg match {
case arg: Int =>
if (isOctal) java.lang.Integer.toOctalString(arg)
else java.lang.Integer.toHexString(arg)
case arg: Long =>
if (isOctal) java.lang.Long.toOctalString(arg)
else java.lang.Long.toHexString(arg)
case _ =>
illegalFormatConversion()
}

I vaguely recall that we needed to make this decision a long time ago, but I do not remember why we settled on this. I'll try and dig in the commit history.

from scala-js.

gzm0 avatar gzm0 commented on June 10, 2024

Commit removing the handling of Byte/Short: 000fb14 / #434

from scala-js.

sjrd avatar sjrd commented on June 10, 2024

Also Duplicate of #2206.

from scala-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.