2009-09-30 6 views
6

で使用されている。これは私のエラーです:のOCaml:エラーが - この式は、xを入力しているが、タイプX

Error: This expression has type nfa but is here used with type nfa 

おそらくこれを引き起こすことが起こって何ができますか?私はemacs tuaregを使用していて、評価ファイルを一つずつ読み込んでいます。時にはこれが起こり、それ以外の時は起こりません。

+1

あなたは、このエラーを生成するコードを投稿することができますか? – 0xFF

答えて

10

ocaml tutorialに詳しい説明があります。トップレベルは古い定義をクリアします再起動

type nfa = int 
let f (x: nfa) = x 

type nfa = int 
let g (x: nfa) = x 

:何が起こったのは、あなたが新しい定義と型定義を影にしているです。

0

更新:

(2013年9月発売)OCamlの4.01.0は、一般的な問題は同じであるが、エラーメッセージが明らかタイプが内部異なるするために、タイプ定義に番号を追加しているので。 トップレベルold OCaml FAQから

完全な例は:

type counter = Counter of int;; (* define a type *) 
type counter = Counter of int 
# let x = Counter 1;;   (* use the new type *) 
val x : counter = Counter 1 
type counter = Counter of int;; (* redefine the type, use it *) 
type counter = Counter of int 
# let incr_counter c = match c with Counter x -> Counter (x + 1);; 
val incr_counter : counter -> counter = <fun> 
# incr_counter x;;    (* now mix old and new defs *) 
Error: This expression has type counter/1029 
     but an expression was expected of type counter/1032 
# 
関連する問題