[fine] No methods assigned to variables!
This commit is contained in:
parent
0c69758b11
commit
bc57978dda
2 changed files with 22 additions and 1 deletions
|
|
@ -708,7 +708,17 @@ impl<'a> Semantics<'a> {
|
|||
None => Type::Error,
|
||||
};
|
||||
|
||||
// TODO: Variables cannot be of type <method>?
|
||||
let declaration_type = match declaration_type {
|
||||
Type::Method(..) => {
|
||||
let start = name.start;
|
||||
let end = name.start + name.as_str().len();
|
||||
self.report_error_span(start, end, "methods cannot be assigned to variables");
|
||||
Type::Error
|
||||
}
|
||||
_ => declaration_type,
|
||||
};
|
||||
|
||||
eprintln!("{} => {}", name, declaration_type);
|
||||
|
||||
let location = match parent.location {
|
||||
Location::Local => Location::Local,
|
||||
|
|
|
|||
11
fine/tests/expression/errors/no_method_variables.fine
Normal file
11
fine/tests/expression/errors/no_method_variables.fine
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class Foo {
|
||||
fun bar(self) {}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
let obj = new Foo {};
|
||||
let f = obj.bar;
|
||||
}
|
||||
|
||||
// @expect-errors:
|
||||
// | 7:6: methods cannot be assigned to variables
|
||||
Loading…
Add table
Add a link
Reference in a new issue