0

I have following code in my do~end scope of some feature:

add (tempA, tempB)

Here, type of arguments are:

tempA: A
tempB: B

Both are declared as local variable.

And, here is prototype of feature add:

add (a: A; b: B)

The compile error I get:

Formal argument type: Generic #1
Actual argument type: detachable Generic #1

How can I instant cast type of "tempA" and "tempB" to Generic type from detachable Generic type? so that I can pass them to add feature.

I am not changing prototype, but I can change type of "tempA" and "tempB" though.

Miku
  • 41
  • 1
  • 5

1 Answers1

2

Until initialized the local variables are treated as detachable. They can be initialized either by assigning values to them

tempA := exprA -- exprA should return a value of type A
tempB := exprB -- exprB should return a value of type B

(e.g. exprA could be a formal argument of the feature in question) or by creating the objects directly:

create tempA
create tempB

(possibly with creation procedures, if necessary, i.e. create tempA.make ...).

Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35