F#错误FS0191:'inherit'声明可能没有'as'绑定

时间:2022-10-13 16:10:31

This error happened after updating to latest may 2009 CTP. Sometimes I do not get the meaning of some error messages. I write this code:

更新到2009年最新的CTP后发生此错误。有时我没有得到一些错误消息的含义。我写这段代码:

type MyClass = class
    inherit Game as base

and I receive this error message:

我收到此错误消息:

error FS0191: 'inherit' declarations may not have 'as' bindings. The keyword 'base' may be used instead. Remove this 'as' binding

错误FS0191:'inherit'声明可能没有'as'绑定。可以使用关键字“base”代替。删除此'as'绑定

I deleted as base from second line

我从第二行删除了作为基础

type MyClass = class
    inherit Game

and program compiled fine (is it that simple?). But, I keep wondering if this would have some unexpected effects. Hence my questions:

程序编译得很好(这很简单吗?)。但是,我一直想知道这是否会产生一些意想不到的效果。因此我的问题:

Is it "may not have 'as' binding" or "cannot have 'as' binding" or "should not have 'as' binding"? What is the meaning of that error?

是“可能没有'作为'约束力'还是”不能拥有'作为'约束力'或“不应该具有'作为'约束力'?那个错误是什么意思?

1 个解决方案

#1


You did the right thing. Once upon a time, if you wanted to refer to the base class, you had to do the 'as base' thing (and could choose any identifier). Now 'base' is a keyword for referring to the base class, and the 'as base' syntax was deprecated and then removed.

你做了正确的事情。曾几何时,如果你想引用基类,你必须做'as base'的事情(并且可以选择任何标识符)。现在'base'是用于引用基类的关键字,并且不推荐使用'as base'语法然后删除它。

(And you're right, it should say 'cannot' instead of 'may not', I'll go fix that right now.)

(你是对的,它应该说'不能'而不是'可能不',我现在就去修复它。)

#1


You did the right thing. Once upon a time, if you wanted to refer to the base class, you had to do the 'as base' thing (and could choose any identifier). Now 'base' is a keyword for referring to the base class, and the 'as base' syntax was deprecated and then removed.

你做了正确的事情。曾几何时,如果你想引用基类,你必须做'as base'的事情(并且可以选择任何标识符)。现在'base'是用于引用基类的关键字,并且不推荐使用'as base'语法然后删除它。

(And you're right, it should say 'cannot' instead of 'may not', I'll go fix that right now.)

(你是对的,它应该说'不能'而不是'可能不',我现在就去修复它。)