diff --git a/rib-lang/src/compiler/byte_code.rs b/rib-lang/src/compiler/byte_code.rs index a65a75c..296862f 100644 --- a/rib-lang/src/compiler/byte_code.rs +++ b/rib-lang/src/compiler/byte_code.rs @@ -53,7 +53,7 @@ impl Display for RibByteCodeGenerationError { write!(f, "Unresolved wasm component for function: {function}") } RibByteCodeGenerationError::UnresolvedWorkerName => { - write!(f, "inline invocation of functions on a worker instance is currently not supported") + write!(f, "inline invocation of functions on an instance expression is currently not supported") } _ => { write!(f, "inline invocation of methods on resource constructor instance is currently not supported") diff --git a/rib-lang/src/compiler/mod.rs b/rib-lang/src/compiler/mod.rs index 1571b3b..9c9ca31 100644 --- a/rib-lang/src/compiler/mod.rs +++ b/rib-lang/src/compiler/mod.rs @@ -182,7 +182,7 @@ pub struct DefaultWorkerNameGenerator; impl GenerateWorkerName for DefaultWorkerNameGenerator { fn generate_worker_name(&self) -> String { let uuid = uuid::Uuid::new_v4(); - format!("worker-{uuid}") + format!("instance-{uuid}") } } diff --git a/rib-lang/src/instance_type.rs b/rib-lang/src/instance_type.rs index 9c770e0..1320d4a 100644 --- a/rib-lang/src/instance_type.rs +++ b/rib-lang/src/instance_type.rs @@ -17,13 +17,13 @@ use std::ops::Deref; // the type of instance becomes more and more precise. // // Please look at `InstanceCreationType` -// for a tangible view on the fact that an instance can be either worker or a resource. +// for a tangible view on the fact that an instance can be either a component instance or a resource. #[derive(Debug, Hash, Clone, Eq, PartialEq, PartialOrd, Ord)] pub enum InstanceType { - // Worker instance: one component's exports (all packages/interfaces merged in the dictionary) + // Component instance: one component's exports (all packages/interfaces merged in the dictionary) Global { worker_name: Option>, - /// Shared across all worker-instance types for one compile — avoids cloning [`FunctionDictionary`] per node. + /// Shared across all instance types for one compile — avoids cloning [`FunctionDictionary`] per node. component: Arc, }, @@ -292,7 +292,7 @@ fn search_function_in_single_package( interfaces.sort(); Err(format!( - "multiple interfaces contain function '{function_name}'; disambiguate with a fully qualified WIT call (e.g. ns:pkg/interface.{{fn}}). interfaces: {}", + "multiple interfaces contain function '{function_name}'. Rib does not currently support disambiguating instance method names across interfaces. interfaces: {}", interfaces.join(", ") )) } @@ -303,7 +303,7 @@ fn search_function_in_multiple_packages( package_map: HashMap, HashSet>>, ) -> Result { let mut error_msg = format!( - "function '{function_name}' exists in multiple packages; use a fully qualified WIT call site to disambiguate: " + "function '{function_name}' exists in multiple packages. Rib does not currently support disambiguating instance method names in this case. Conflicting exports: " ); let mut package_interface_list = package_map diff --git a/rib-lang/src/interpreter/rib_interpreter.rs b/rib-lang/src/interpreter/rib_interpreter.rs index 3a9bb57..6b16ba7 100644 --- a/rib-lang/src/interpreter/rib_interpreter.rs +++ b/rib-lang/src/interpreter/rib_interpreter.rs @@ -733,7 +733,7 @@ mod internal { Some(worker_id) => { let value_and_type = worker_id.get_val().ok_or_else(|| { internal_corrupted_state!( - "expected a worker name to be present in the environment, but it was not found" + "expected an instance name to be present in the environment, but it was not found" ) })?; @@ -1212,7 +1212,7 @@ mod internal { .map(|x| { x.get_val().ok_or_else(|| { internal_corrupted_state!( - "failed to get a worker variable id for function {}", + "failed to get an instance variable id for function {}", function_name ) }) @@ -1220,7 +1220,7 @@ mod internal { .transpose()? .ok_or_else(|| { internal_corrupted_state!( - "failed to find a worker with id {}", + "failed to find an instance with id {}", variable_id.name() ) })?; @@ -1230,7 +1230,7 @@ mod internal { .get_literal() .map(|v| v.as_string()) .ok_or_else(|| { - internal_corrupted_state!("failed to get a worker name for variable") + internal_corrupted_state!("failed to get an instance name for variable") })?; let result = interpreter_env @@ -3328,7 +3328,7 @@ mod tests { assert_eq!( error.to_string(), - "inline invocation of functions on a worker instance is currently not supported" + "inline invocation of functions on an instance expression is currently not supported" ); } @@ -3349,7 +3349,7 @@ mod tests { let compiled = compiler.compile(expr).unwrap_err().to_string(); - assert_eq!(compiled, "error in the following rib found at line 2, column 28\n`instance`\ncause: `instance` is a reserved keyword\nhelp: use `instance()` instead of `instance` to create an ephemeral worker instance.\nhelp: for a durable worker, use `instance(\"foo\")` where `\"foo\"` is the worker name\n".to_string()); + assert_eq!(compiled, "error in the following rib found at line 2, column 28\n`instance`\ncause: `instance` is a reserved keyword\nhelp: use `instance()` instead of `instance` to create an ephemeral instance.\nhelp: for a named instance, use `instance(\"foo\")` where `\"foo\"` is the instance name\n".to_string()); } #[test] @@ -3372,7 +3372,7 @@ mod tests { assert_eq!( compilation_error, - "error in the following rib found at line 3, column 30\n`x.bar(\"bar\")`\ncause: invalid function call `bar`\nmultiple interfaces contain function 'bar'; disambiguate with a fully qualified WIT call (e.g. ns:pkg/interface.{fn}). interfaces: api1, api2\n".to_string() + "error in the following rib found at line 3, column 30\n`x.bar(\"bar\")`\ncause: invalid function call `bar`\nmultiple interfaces contain function 'bar'. Rib does not currently support disambiguating instance method names across interfaces. interfaces: api1, api2\n".to_string() ); } @@ -3494,7 +3494,7 @@ mod tests { assert_eq!( compilation_error, - "error in the following rib found at line 3, column 30\n`worker.bar(\"bar\")`\ncause: invalid function call `bar`\nmultiple interfaces contain function 'bar'; disambiguate with a fully qualified WIT call (e.g. ns:pkg/interface.{fn}). interfaces: api1, api2\n".to_string() + "error in the following rib found at line 3, column 30\n`worker.bar(\"bar\")`\ncause: invalid function call `bar`\nmultiple interfaces contain function 'bar'. Rib does not currently support disambiguating instance method names across interfaces. interfaces: api1, api2\n".to_string() ); } @@ -3542,7 +3542,7 @@ mod tests { assert_eq!( compiled, - "error in the following rib found at line 3, column 30\n`worker.qux(\"bar\")`\ncause: invalid function call `qux`\nfunction 'qux' exists in multiple packages; use a fully qualified WIT call site to disambiguate: amazon:shopping-cart (interfaces: api1), wasi:clocks (interfaces: monotonic-clock)\n".to_string() + "error in the following rib found at line 3, column 30\n`worker.qux(\"bar\")`\ncause: invalid function call `qux`\nfunction 'qux' exists in multiple packages. Rib does not currently support disambiguating instance method names in this case. Conflicting exports: amazon:shopping-cart (interfaces: api1), wasi:clocks (interfaces: monotonic-clock)\n".to_string() ); } @@ -4758,8 +4758,8 @@ mod tests { } } - // The interpreter that always returns a record value consisting of function name, worker name etc - // for every function calls in Rib, so tests can assert the invoke target (worker name, function, args). + // The interpreter that always returns a record value consisting of function name, instance name, etc. + // for every function calls in Rib, so tests can assert the invoke target (instance name, function, args). pub(crate) fn interpreter_with_resource_function_invoke_impl( rib_input: Option, ) -> Interpreter { @@ -5165,7 +5165,7 @@ mod tests { } // A pass through function simply pass through the information embedded in a function call - // such as function name, the worker name and the arguments used to invoke the call + // such as function name, the instance name and the arguments used to invoke the call // allowing us to cross verify if the invoke is correct pub(crate) fn test_deps_for_pass_through_function() -> RibTestDeps { let exports = vec![WitExport::Function(WitFunction { diff --git a/rib-lang/src/type_checker/checker.rs b/rib-lang/src/type_checker/checker.rs index 447b210..ff9b871 100644 --- a/rib-lang/src/type_checker/checker.rs +++ b/rib-lang/src/type_checker/checker.rs @@ -271,7 +271,7 @@ fn try_invalid_function_calls_for_node( FunctionCallError::InvalidFunctionCall { function_name: function_name.function.name_pretty().to_string(), source_span: node.source_span.clone(), - message: "function call is not associated with a wasm component. make sure component functions are called after creating an instance using `instance()`".to_string(), + message: "function call is not associated with a wasm component. make sure component functions are called after creating an instance using `instance()`".to_string(), } .into(), ); @@ -324,8 +324,8 @@ fn call_type_node_additional_detail(ct: &CallTypeNode) -> String { CallTypeNode::InstanceCreation(ic) => match ic { InstanceCreationNode::WitWorker { worker_name, .. } => { let wn = worker_name - .map(|_| "(worker expr)") - .map_or(String::new(), |s| format!(", with worker `{s}`")); + .map(|_| "(instance name expr)") + .map_or(String::new(), |s| format!(", with instance name `{s}`")); format!("cannot determine the type of instance creation `{wn}`") } InstanceCreationNode::WitResource { diff --git a/rib-lang/src/type_inference/identify_instance_creation.rs b/rib-lang/src/type_inference/identify_instance_creation.rs index 37535b4..e9ad8e1 100644 --- a/rib-lang/src/type_inference/identify_instance_creation.rs +++ b/rib-lang/src/type_inference/identify_instance_creation.rs @@ -51,10 +51,10 @@ fn search_for_invalid_instance_declarations_arena( if variable_id.name() == "instance" && variable_id.is_global() { return Err(CustomError::new(span, "`instance` is a reserved keyword") .with_help_message( - "use `instance()` instead of `instance` to create an ephemeral worker instance.", + "use `instance()` instead of `instance` to create an ephemeral instance.", ) .with_help_message( - "for a durable worker, use `instance(\"foo\")` where `\"foo\"` is the worker name", + "for a named instance, use `instance(\"foo\")` where `\"foo\"` is the instance name", ) .into()); } diff --git a/rib-lang/src/type_inference/type_pull_up.rs b/rib-lang/src/type_inference/type_pull_up.rs index ed6eff7..d2aa970 100644 --- a/rib-lang/src/type_inference/type_pull_up.rs +++ b/rib-lang/src/type_inference/type_pull_up.rs @@ -342,7 +342,7 @@ fn handle_residual_method_invokes_arena( source_span: source_span.clone(), help_message: vec![], message: format!( - "invalid method invocation `{lhs_name}.{method}`. make sure `{lhs_name}` is defined and is a valid instance type (i.e, resource or worker)" + "invalid method invocation `{lhs_name}.{method}`. make sure `{lhs_name}` is defined and is a valid instance type (including resources)" ), } .into()) diff --git a/rib-lang/src/type_inference/worker_function_invocation.rs b/rib-lang/src/type_inference/worker_function_invocation.rs index 63385d9..c4eb004 100644 --- a/rib-lang/src/type_inference/worker_function_invocation.rs +++ b/rib-lang/src/type_inference/worker_function_invocation.rs @@ -350,7 +350,7 @@ pub fn infer_function_invokes( FunctionCallError::invalid_function_call( &method, span.clone(), - "invalid worker function invoke. Expected to be an instance type", + "invalid instance method invoke. expected lhs to be an instance type", ), )); } diff --git a/rib-repl/README.md b/rib-repl/README.md index 17b6f39..8e0fd9a 100644 --- a/rib-repl/README.md +++ b/rib-repl/README.md @@ -10,8 +10,8 @@ Example: Once the component is loaded, the following will result in `3`, if the ``` >>> let a = instance(); ->>> let b = a.increment_and_get(); ->>> let c = a.increment_and_get(); +>>> let b = a.increment-and-get(); +>>> let c = a.increment-and-get(); >>> b + c ``` diff --git a/rib-repl/src/instance_name_gen.rs b/rib-repl/src/instance_name_gen.rs index ae5c513..3412650 100644 --- a/rib-repl/src/instance_name_gen.rs +++ b/rib-repl/src/instance_name_gen.rs @@ -5,9 +5,9 @@ use std::sync::Arc; // When it comes to REPL, unlike the regular Rib execution, // it recompiles from the start anytime to figure out the types -// however it shouldn't result in a variable having a different instance of worker, -// meaning different worker name. Rib internally generates a worker name at compile time -// for instances without worker-name, i.e, `instance()` compared to `instance("my-worker")`. +// however it shouldn't result in a variable having a different logical instance, +// meaning a different generated instance name. Rib internally generates an instance name at compile time +// for `instance()` compared to `instance("my-worker")`. pub struct ReplInstanceNameGen { pub instance_count: u64, pub worker_name_cache: HashMap, @@ -35,7 +35,7 @@ impl ReplInstanceNameGen { return name.clone(); } let uuid = uuid::Uuid::new_v4(); - let name = format!("worker-{}-{}", self.instance_count, uuid); + let name = format!("instance-{}-{}", self.instance_count, uuid); self.worker_name_cache .insert(self.instance_count, name.clone()); name diff --git a/rib-repl/src/invoke.rs b/rib-repl/src/invoke.rs index 2babdfa..6ad1183 100644 --- a/rib-repl/src/invoke.rs +++ b/rib-repl/src/invoke.rs @@ -24,7 +24,7 @@ pub trait ComponentFunctionInvoke { // Note: Currently, the Rib interpreter supports only one component, so the // `RibFunctionInvoke` trait in the `golem-rib` module does not include `component_id` in -// the `invoke` arguments. It only requires the optional worker name, function name, and arguments. +// the `invoke` arguments. It only requires the optional instance name, function name, and arguments. // Once multi-component support is added, the trait will be updated to include `component_id`, // and we can use it directly instead of `WorkerFunctionInvoke` in the `golem-rib-repl` module. pub(crate) struct ReplRibFunctionInvoke { diff --git a/rib-repl/src/repl_state.rs b/rib-repl/src/repl_state.rs index 497e562..d0ef27d 100644 --- a/rib-repl/src/repl_state.rs +++ b/rib-repl/src/repl_state.rs @@ -46,8 +46,8 @@ impl ReplState { } // This reset is to ensure the rib compiler the REPL can reuse the previous - // compilations (within the same session) worker names generated. i.e, before every compilation we reset the instance count, - // and there by, for the new script, the instance creation will end up reusing already generated worker names. + // compilations (within the same session) instance names generated. i.e, before every compilation we reset the instance count, + // and thereby, for the new script, the instance creation will end up reusing already generated instance names. pub fn reset_instance_count(&self) { self.worker_name_gen.write().unwrap().reset_instance_count(); }