Skip to content

Commit 8b28c72

Browse files
committed
Support applying a value to an inline function
1 parent 0c3e87d commit 8b28c72

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

quiver-compiler/src/compiler.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,12 +1293,15 @@ impl<'a> Compiler<'a> {
12931293
self.compile_block(block, block_parameter, None)
12941294
}
12951295
ast::Term::Function(func) => {
1296-
if value_type.is_some() {
1297-
return Err(Error::FeatureUnsupported(
1298-
"Function cannot be applied to value".to_string(),
1299-
));
1296+
// Compile the function itself
1297+
let function_type = self.compile_function(func)?;
1298+
1299+
// If a value is being piped to it, apply the value
1300+
if let Some(val_type) = value_type {
1301+
self.apply_value_to_type(function_type, val_type)
1302+
} else {
1303+
Ok(function_type)
13001304
}
1301-
self.compile_function(func)
13021305
}
13031306
ast::Term::Access(access) => {
13041307
match &access.identifier {

quiver-tests/tests/functions.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,10 @@ fn test_function_parameter_contravariance() {
165165
"#,
166166
);
167167
}
168+
169+
#[test]
170+
fn test_apply_value_to_inline_function() {
171+
quiver()
172+
.evaluate("5 ~> #int { ~> [~, 2] ~> <add> }")
173+
.expect("7");
174+
}

0 commit comments

Comments
 (0)