Giter Club home page Giter Club logo

Comments (6)

thehowl avatar thehowl commented on July 16, 2024 1

Let me add an issue related to this. I'll avoid making this a separate issue, mostly because I believe Maxwell's #1426 likely tackles this as well, but I want to publicly document another situation where this creates issues.

Consider the following code:

package main

func main() {
	x := 1024
	p := 10
	if x != 1<<p {
		println("WHAT?")
	}
}

This will print WHAT?, unexpectedly (Go prints nothing).

Because x and 1 << p are different types (per the issue title, 1 << p is a Bigint), they are considered different.

Naturally, changing 1 to int(1) makes the code work as it should. ;_;

@ltzmaxwell, rest assured I will try to review your PR as soon as possible because tracing down bugs like these destroys my mental sanity.

from gno.

ltzmaxwell avatar ltzmaxwell commented on July 16, 2024 1

@ltzmaxwell I'm getting WHAT? on master :)

Or do you mean on your branch?

Oh yes, I mean on my branch. Sorry for the ambiguity.

from gno.

deelawn avatar deelawn commented on July 16, 2024

I'm not sure but on the surface the solution to this may be related to the solution in #1423

from gno.

ltzmaxwell avatar ltzmaxwell commented on July 16, 2024

Hi,
I've submitted a fix at #1426. It's about the type check/conversion for some special case, e.g. shift expr or any expr involve a shift expr.

from gno.

ltzmaxwell avatar ltzmaxwell commented on July 16, 2024

Hi Morgan @thehowl,
this works:

package main

func main() {
	x := 1024
	p := 10
	if x != 1<<p {
		println("WHAT?")
	} else {
		println("nothing")
	}
}

// Output:
// nothing

from gno.

thehowl avatar thehowl commented on July 16, 2024

@ltzmaxwell I'm getting WHAT? on master :)

Or do you mean on your branch?

from gno.

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.