winglang/wing
在 GitHub 查看Errors are being displayed in a different order from the line that generated the error in the code
Open
#2,637 建立於 2023年5月23日
good first issue⌨️ cli✨ enhancement🛠️ compiler
倉庫指標
- Star
- (5,385 star)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
bring cloud;
class C1 {
x:num;
// ^ Preflight field "x" is not initialized
}
class C2 {}
new C2(1);
//^^^^^^^ Expected 0 argument(s) but got 1
class C9 {}
new C9(token: "1");
//^^^^^^^ Expected 0 named argument(s)"
class C10 {
new(foo: str)
}
new C10();
//^^^^^^^ Expected 1 required positional arguments but got 0 when instantiating "C5"
new C10(foo: "bar");
//^^^^^^^ Expected 1 positional argument(s) but got 0
new C10("hello", foo: "bar");
//^^^^^^^ class C10 does not expect any named argument
class C3 {
x: num;
new() {
this.x = "Hi";
//^^^^ Expected type to be "num", but got "str" instead
}
}
class C4 {
inflight var x: num;
//^ Inflight field "x" is not initialized
inflight y: str;
//^ Inflight field "y" is not initialized
}
class C5 {
inflight x: num;
//^ Inflight field "x" is not initialized
inflight new() {}
}
class C6 {
inflight x: num;
//^ Inflight field "x" is not initialized
y: num;
//^ Preflight field "y" is not initialized
new() {
this.x = 1;
//^ "x" cannot be initialized in the Preflight initializer
}
inflight new() {
this.y = 1;
//^ "y" cannot be initialized in the Inflight initializer
}
}
let x = 5;
class C7 extends x {
//^ Expected 'x' to be a type but it's a variable
}
struct S1 {}
class C8 extends S1 {
//^^ Preflight class C8's parent is not a class
}
class C11 extends C11 {
//^^^ Class cannot extend itself
}
Feature Spec
Some errors are being generated out of order compared to the generating code.
error: \\"y\\" cannot be initialized in the Inflight initializer
--> ../../../examples/tests/invalid/class.w:45:10
|
45 | this.y = 1;
| ^ \\"y\\" cannot be initialized in the Inflight initializer
error: \\"x\\" cannot be initialized in the Preflight initializer
--> ../../../examples/tests/invalid/class.w:40:10
|
40 | this.x = 1;
| ^ \\"x\\" cannot be initialized in the Preflight initializer
Use Cases
It would be interesting to display the errors following the sequence of lines from the original code.
Implementation Notes
No response
Component
Compiler
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.