Coder Social home page Coder Social logo

Comments (7)

eckertliam avatar eckertliam commented on May 31, 2024 1

@Anton-4 are you working on a fix for this? I would like to give it a shot.

from roc.

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

No, I've now assigned you to this issue :)
Thanks for your help @eckertliam!

from roc.

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

Due to the multiple type mismatches this example is pretty difficult so if we can get a simpler case to investigate that would be great :)

from roc.

jwoudenberg avatar jwoudenberg commented on May 31, 2024

This might be simpler example:

interface Foo
    exposes [bar]
    imports []

foo : a, (a -> a) -> a
foo = \x, f -> bar x f

bar : a, (a -> a) -> a
bar = \x, f ->
    baz : a
    baz = f x

    foo x f

It fails with just the single error:

── TYPE MISMATCH in Foo.roc ────────────────────────────────────────────────────

Something is off with the body of the baz definition:

10│      baz : a
11│      baz = f x
               ^^^

This f call produces:

    a

But the type annotation on baz says it should be:

    a

────────────────────────────────────────────────────────────────────────────────

1 error and 1 warning found in 26 ms

The error goes away after any of the following changes:

  • Remove implementation of baz
  • Remove type annotation of baz
  • Remove type annotation of bar
  • Remove implementation of foo

from roc.

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

Awesome, thanks @jwoudenberg :)

from roc.

ayazhafiz avatar ayazhafiz commented on May 31, 2024

I don't think either of these should actually be type errors. Unless I'm misunderstanding something I think the programs should compile fine. The issue is that a in the type annotation is not used in the inner annotations' a.

from roc.

lukewilliamboswell avatar lukewilliamboswell commented on May 31, 2024

I wonder if we could add a suggestion? maybe it would be possible to detect this somehow and provide a suggestion like "the types are different even though they are have the same name"

Or perhaps there is a way to prevent this kind of issue by making it invalid to use the same type variable in an inner annotation?

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.