Allow (42 : Text & Integer) at the end of function (#11588)

Bypassing failing check.
This commit is contained in:
Jaroslav Tulach 2024-11-20 09:14:38 +01:00 committed by somebody1234
parent 1a5b194f51
commit 9b1f2efbfe
2 changed files with 25 additions and 1 deletions

View File

@ -318,7 +318,7 @@ case object TypeSignatures extends IRPass {
case a => Some(resolveExpression(a)) case a => Some(resolveExpression(a))
} ::: lastSignature } ::: lastSignature
.map({ .map({
case asc @ Type.Ascription(_: Name, sig, comment, _, _) => case asc @ Type.Ascription(_, sig, comment, _, _) =>
asc.updateMetadata( asc.updateMetadata(
new MetadataPair(this, Signature(sig, comment)) new MetadataPair(this, Signature(sig, comment))
) )

View File

@ -1026,6 +1026,30 @@ public class SignatureTest extends ContextTest {
} }
} }
@Test
public void returnTypeCheckByLastStatementOfMain() throws Exception {
final URI uri = new URI("memory://rts.enso");
final Source src =
Source.newBuilder(
"enso",
"""
from Standard.Base import all
fn =
(42 : Text & Integer)
Text.from (that:Integer) = that.to_text
""",
uri.getAuthority())
.uri(uri)
.buildLiteral();
var module = ctx.eval(src);
var main = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "fn");
assertEquals(42, main.asInt());
assertEquals("42", main.asString());
}
/** /**
* Similar scenario to {@code returnTypeCheckOptInError}, but with the opt out signature the check * Similar scenario to {@code returnTypeCheckOptInError}, but with the opt out signature the check
* is not currently performed. * is not currently performed.