Comments (7)
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.
Thanks for this minimal reproduction @jwoudenberg! This is an interesting one :)
The error message is saying Roc is expecting an
a
and getting ana
, 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.
Can we close this in favor of #6595 @jwoudenberg?
from roc.
Sure, thank you!
from roc.
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.
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.
Interesting! Yeah, this warrants further investigation.
from roc.
Related Issues (20)
- Don't suggest using `... where * implements ...`
- repl inferred type can't be used
- feat: suppress REPL startup message HOT 1
- bug: comments not accepted in REPL HOT 4
- incomprehensible-to-novice error message when omitting parentheses HOT 1
- change comment in repl behavior
- Compiler errors could be better when using wrong syntax for 'rest' in list patterns
- space after backslash in function definition causes panic
- `roc build` appears to hang with underscored function name
- request: novice-readable error message for task/function mixups HOT 2
- roc format doc comments without space
- Roc format panic on valid code HOT 2
- Odd string to F64 parsing bugs in Roc REPL (old_linux_x86_64)
- An odd case of a segmentation fault on old_linux_x86_64
- Compiler Panic "constructor must be known in the indexable type if we are exhautiveness checking"
- Improve type mismatch error: this need to be `a` but it is `a` HOT 5
- CudaText has new lexer 'Roc' HOT 1
- Surgical linker bug on Windows causes segfault
- Pattern matching panic HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roc.