@@ -16,7 +16,7 @@ mod typing;
1616use crate :: arena:: Arena ;
1717use crate :: lexer:: tokenize;
1818use crate :: prelude:: {
19- Analysis , AnalysisOptions , FunArgs , Typed , display_type, name_to_type, parse,
19+ Analysis , AnalysisOptions , FunArgs , Scope , Typed , display_type, name_to_type, parse,
2020} ;
2121use crate :: token:: Token ;
2222pub use ast:: * ;
@@ -550,8 +550,8 @@ impl Session {
550550 /// - `"date"` → [`Type::Date`]
551551 /// - `"time"` → [`Type::Time`]
552552 /// - `"datetime"` → [`Type::DateTime`]
553- pub fn get_type_from_name ( & mut self , name : & str ) -> Option < Type > {
554- let str_ref = self . arena . strings . alloc ( name) ;
553+ pub fn get_type_from_name ( & self , name : & str ) -> Option < Type > {
554+ let str_ref = self . arena . strings . str_ref ( name) ? ;
555555 name_to_type ( & self . arena , & self . options , str_ref)
556556 }
557557
@@ -560,8 +560,8 @@ impl Session {
560560 /// Function types display optional parameters with a `?` suffix. For example,
561561 /// a function with signature `(boolean, number?) -> string` accepts 1 or 2 arguments.
562562 /// Aggregate functions use `=>` instead of `->` in their signature.
563- pub fn display_type ( & self , tpe : & Type ) -> String {
564- display_type ( & self . arena , * tpe)
563+ pub fn display_type ( & self , tpe : Type ) -> String {
564+ display_type ( & self . arena , tpe)
565565 }
566566
567567 /// Creates an [`Analysis`] instance for fine-grained control over static analysis.
@@ -581,4 +581,9 @@ impl Session {
581581 pub fn arena_mut ( & mut self ) -> & mut Arena {
582582 & mut self . arena
583583 }
584+
585+ /// Returns the global [`Scope`]
586+ pub fn global_scope ( & self ) -> & Scope {
587+ & self . options . default_scope
588+ }
584589}
0 commit comments