From 374f48a160acce84f3df09c4c645831d34a8fb81 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Fri, 24 Nov 2023 15:50:33 -0800 Subject: [PATCH] Fix issues for engine --- .../validation_files/class/secure_types.baml | 39 ++++++++++--------- .../class/spelling_error.baml | 5 ++- .../validation_files/class/unknown_type.baml | 3 +- .../nonexistent_input_output_types.baml | 5 ++- .../functions/valid_multiple_arg.baml | 7 ++++ 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/engine/baml-lib/baml/tests/validation_files/class/secure_types.baml b/engine/baml-lib/baml/tests/validation_files/class/secure_types.baml index 45f2268c4..44cdc6721 100644 --- a/engine/baml-lib/baml/tests/validation_files/class/secure_types.baml +++ b/engine/baml-lib/baml/tests/validation_files/class/secure_types.baml @@ -23,7 +23,8 @@ class ComplexTypes { -// error: Type `apple_pie` does not exist. + +// error: Type `apple_pie` does not exist. Did you mean one of these: `ComplexTypes`, `float`, `bool`, `string`, `int`? // --> class/secure_types.baml:3 // | // 2 | class ComplexTypes { @@ -41,19 +42,19 @@ class ComplexTypes { // 4 | b (int, {bool: string?}, (char | float)[][] | long_word_123.foobar[]) // 5 | c apple123_456_pie | (stringer, bool[], (int | char))[] // | -// error: Type `stringer` does not exist. Did you mean `string`? +// error: Type `stringer` does not exist. Did you mean one of these: `string`, `int`, `float`, `bool`? // --> class/secure_types.baml:5 // | // 4 | b (int, {bool: string?}, (char | float)[][] | long_word_123.foobar[]) // 5 | c apple123_456_pie | (stringer, bool[], (int | char))[] // | -// error: Type `double` does not exist. +// error: Type `double` does not exist. Did you mean one of these: `bool`, `string`, `int`, `float`, `ComplexTypes`? // --> class/secure_types.baml:7 // | // 6 | d {int[][]: ((int | float) | char[])} // 7 | e ((int, string | char) | ((float, double) | long[], bool)[][][]) // | -// error: Type `long` does not exist. +// error: Type `long` does not exist. Did you mean one of these: `int`, `float`, `bool`, `string`? // --> class/secure_types.baml:7 // | // 6 | d {int[][]: ((int | float) | char[])} @@ -71,25 +72,25 @@ class ComplexTypes { // 8 | f VeryLongWord_With_123_Numbers[][][][] // 9 | g (int, (float, char, bool), string[]) | tuple_inside_tuple[] // | -// error: Type `apple` does not exist. +// error: Type `apple` does not exist. Did you mean one of these: `bool`, `int`, `float`, `string`, `ComplexTypes`? // --> class/secure_types.baml:11 // | // 10 | h (((int | string)[]) | {bool[][]: char[]}) // 11 | i (apple, banana | cherry | date_fruit | eggplant_vegetable)[] // | -// error: Type `banana` does not exist. +// error: Type `banana` does not exist. Did you mean one of these: `string`, `int`, `float`, `bool`? // --> class/secure_types.baml:11 // | // 10 | h (((int | string)[]) | {bool[][]: char[]}) // 11 | i (apple, banana | cherry | date_fruit | eggplant_vegetable)[] // | -// error: Type `cherry` does not exist. +// error: Type `cherry` does not exist. Did you mean one of these: `string`, `int`, `float`, `bool`, `ComplexTypes`? // --> class/secure_types.baml:11 // | // 10 | h (((int | string)[]) | {bool[][]: char[]}) // 11 | i (apple, banana | cherry | date_fruit | eggplant_vegetable)[] // | -// error: Type `date_fruit` does not exist. +// error: Type `date_fruit` does not exist. Did you mean one of these: `string`, `float`, `int`, `bool`? // --> class/secure_types.baml:11 // | // 10 | h (((int | string)[]) | {bool[][]: char[]}) @@ -101,19 +102,19 @@ class ComplexTypes { // 10 | h (((int | string)[]) | {bool[][]: char[]}) // 11 | i (apple, banana | cherry | date_fruit | eggplant_vegetable)[] // | -// error: Type `double` does not exist. +// error: Type `double` does not exist. Did you mean one of these: `bool`, `string`, `int`, `float`, `ComplexTypes`? // --> class/secure_types.baml:12 // | // 11 | i (apple, banana | cherry | date_fruit | eggplant_vegetable)[] // 12 | j ((char, int[][], (bool | string[][])) | double[][][][], (float, int)[]) // | -// error: Type `long` does not exist. +// error: Type `long` does not exist. Did you mean one of these: `int`, `float`, `bool`, `string`? // --> class/secure_types.baml:13 // | // 12 | j ((char, int[][], (bool | string[][])) | double[][][][], (float, int)[]) // 13 | k {string[]: (int | long[])} | {float[][]: double[][]} // | -// error: Type `double` does not exist. +// error: Type `double` does not exist. Did you mean one of these: `bool`, `string`, `int`, `float`, `ComplexTypes`? // --> class/secure_types.baml:13 // | // 12 | j ((char, int[][], (bool | string[][])) | double[][][][], (float, int)[]) @@ -125,49 +126,49 @@ class ComplexTypes { // 13 | k {string[]: (int | long[])} | {float[][]: double[][]} // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // | -// error: Type `tuple_1` does not exist. +// error: Type `tuple_1` does not exist. Did you mean one of these: `float`, `bool`, `string`, `int`, `ComplexTypes`? // --> class/secure_types.baml:15 // | // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // | -// error: Type `tuple_2` does not exist. +// error: Type `tuple_2` does not exist. Did you mean one of these: `float`, `bool`, `string`, `int`, `ComplexTypes`? // --> class/secure_types.baml:15 // | // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // | -// error: Type `tuple_3` does not exist. +// error: Type `tuple_3` does not exist. Did you mean one of these: `float`, `bool`, `string`, `int`, `ComplexTypes`? // --> class/secure_types.baml:15 // | // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // | -// error: Type `tuple_4` does not exist. +// error: Type `tuple_4` does not exist. Did you mean one of these: `float`, `bool`, `string`, `int`, `ComplexTypes`? // --> class/secure_types.baml:15 // | // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // | -// error: Type `tuple_5` does not exist. +// error: Type `tuple_5` does not exist. Did you mean one of these: `float`, `bool`, `string`, `int`, `ComplexTypes`? // --> class/secure_types.baml:15 // | // 14 | l AlphaNumeric_123_456_789 | (int, bool?) | char[] // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // | -// error: Type `another_key` does not exist. +// error: Type `another_key` does not exist. Did you mean one of these: `string`, `int`, `ComplexTypes`, `float`, `bool`? // --> class/secure_types.baml:16 // | // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // 16 | n {complex_key_type[]: {another_key: (int | string[])}} // | -// error: Type `complex_key_type` does not exist. +// error: Type `complex_key_type` does not exist. Did you mean `ComplexTypes`? // --> class/secure_types.baml:16 // | // 15 | m (tuple_1, tuple_2 | tuple_3, (tuple_4, tuple_5))[] // 16 | n {complex_key_type[]: {another_key: (int | string[])}} // | -// error: Type `double` does not exist. +// error: Type `double` does not exist. Did you mean one of these: `bool`, `string`, `int`, `float`, `ComplexTypes`? // --> class/secure_types.baml:17 // | // 16 | n {complex_key_type[]: {another_key: (int | string[])}} diff --git a/engine/baml-lib/baml/tests/validation_files/class/spelling_error.baml b/engine/baml-lib/baml/tests/validation_files/class/spelling_error.baml index 05529681c..edb2ccd78 100644 --- a/engine/baml-lib/baml/tests/validation_files/class/spelling_error.baml +++ b/engine/baml-lib/baml/tests/validation_files/class/spelling_error.baml @@ -10,13 +10,14 @@ class InterfaceOne { -// error: Type `strin` does not exist. Did you mean `string`? + +// error: Type `strin` does not exist. Did you mean one of these: `string`, `int`, `float`, `bool`, `InterfaceOne`, `InterfaceTwo`? // --> class/spelling_error.baml:2 // | // 1 | class InterfaceTwo { // 2 | interface strin // | -// error: Type `InterfaceT` does not exist. Did you mean `InterfaceTwo`? +// error: Type `InterfaceT` does not exist. Did you mean one of these: `InterfaceTwo`, `InterfaceOne`, `int`, `string`, `float`, `bool`? // --> class/spelling_error.baml:6 // | // 5 | class InterfaceOne { diff --git a/engine/baml-lib/baml/tests/validation_files/class/unknown_type.baml b/engine/baml-lib/baml/tests/validation_files/class/unknown_type.baml index 0cbc3689f..e76aea565 100644 --- a/engine/baml-lib/baml/tests/validation_files/class/unknown_type.baml +++ b/engine/baml-lib/baml/tests/validation_files/class/unknown_type.baml @@ -7,7 +7,8 @@ class InterfaceTwo { -// error: Type `Bar` does not exist. + +// error: Type `Bar` does not exist. Did you mean one of these: `int`, `bool`, `float`, `string`? // --> class/unknown_type.baml:3 // | // 2 | interface string diff --git a/engine/baml-lib/baml/tests/validation_files/functions/nonexistent_input_output_types.baml b/engine/baml-lib/baml/tests/validation_files/functions/nonexistent_input_output_types.baml index 08078ac09..8d3a4f21e 100644 --- a/engine/baml-lib/baml/tests/validation_files/functions/nonexistent_input_output_types.baml +++ b/engine/baml-lib/baml/tests/validation_files/functions/nonexistent_input_output_types.baml @@ -7,13 +7,14 @@ function Foo { -// error: Type `Bar` does not exist. + +// error: Type `Bar` does not exist. Did you mean one of these: `int`, `bool`, `float`, `string`? // --> functions/nonexistent_input_output_types.baml:3 // | // 2 | function Foo { // 3 | input Bar // | -// error: Type `Baz` does not exist. +// error: Type `Baz` does not exist. Did you mean one of these: `int`, `bool`, `float`, `string`? // --> functions/nonexistent_input_output_types.baml:4 // | // 3 | input Bar diff --git a/engine/baml-lib/baml/tests/validation_files/functions/valid_multiple_arg.baml b/engine/baml-lib/baml/tests/validation_files/functions/valid_multiple_arg.baml index df868db5c..664e3b60f 100644 --- a/engine/baml-lib/baml/tests/validation_files/functions/valid_multiple_arg.baml +++ b/engine/baml-lib/baml/tests/validation_files/functions/valid_multiple_arg.baml @@ -11,3 +11,10 @@ function ExtractAllergies { input (hello: string, world: string) output Allergies[] } + +// error: Type `Allergies` does not exist. Did you mean one of these: `string`, `Bar`, `int`, `float`, `bool`? +// --> functions/valid_multiple_arg.baml:12 +// | +// 11 | input (hello: string, world: string) +// 12 | output Allergies[] +// |