Coder Social home page Coder Social logo

Comments (7)

jwoudenberg avatar jwoudenberg commented on May 31, 2024 1

If I try with this simple code sample:

interface Foo
    exposes [foo]
    imports []

foo : U8 -> U8
foo = \_ -> {}

bar : U8
bar = foo 4

Then I just get a compile error for foo. The compiler doesn't give an additional compiler error in bar, which uses foo correctly according to its type signature, but not according to its implementation.

This behavior is matches my expectations too. I often add type signatures to contain type errors in a bit of code, making sure that if I make an error in one place it doesn't result in a type error in a completely different bit of code. That does appear to be happening here.

Going to reopen in that light, but please let me know if you disagree!

from roc.

Anton-4 avatar Anton-4 commented on May 31, 2024

Thanks for this minimal reproduction @jwoudenberg! This is an interesting one :)

The error message is saying Roc is expecting an a and getting an a, so what's the problem?

The a is scoped to one definition, not to the entire function or file, so those are not inherently the same a. That being said, I don't know why that mismatch occurs 😄 I'll open a new issue for that.

It's weird that adding an implementation for one function creates a compiler error in an entirely different function.

Note that you did not just add an implementation here. The type does not match the implementation, so I can see how this changes things when the compiler tries to make the implementation work.

In my original case I got 34 extra errors in various seemingly unrelated parts of the code instead of just the one here, and those 34 burried the useful error

I also think these were caused by the compiler trying to make the implementation work with a different type then before.

from roc.

Anton-4 avatar Anton-4 commented on May 31, 2024

Can we close this in favor of #6595 @jwoudenberg?

from roc.

jwoudenberg avatar jwoudenberg commented on May 31, 2024

Sure, thank you!

from roc.

jwoudenberg avatar jwoudenberg commented on May 31, 2024

Hey @Anton-4 , quick follow up question to your comments:

Note that you did not just add an implementation here. The type does not match the implementation, so I can see how this changes things when the compiler tries to make the implementation work.

I also think these were caused by the compiler trying to make the implementation work with a different type then before.

Do you mean to say that the compiler will infer the correct type for invalidFn which is different from the one I specified, and that inferred type then causes a type-error in validFn?

from roc.

Anton-4 avatar Anton-4 commented on May 31, 2024

Do you mean to say that the compiler will infer the correct type for invalidFn which is different from the one I specified, and that inferred type then causes a type-error in validFn?

I believe that is the case, I'd have to do some investigating to confirm that.

from roc.

Anton-4 avatar Anton-4 commented on May 31, 2024

Interesting! Yeah, this warrants further investigation.

from roc.

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.