MCPcopy Index your code
hub / github.com/endbasic/endbasic / test_local_shadows_global

Function test_local_shadows_global

core/src/compiler/syms.rs:652–665  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

650
651 #[test]
652 fn test_local_shadows_global() -> Result<()> {
653 let upcalls = HashMap::default();
654 let mut global = GlobalSymtable::new(upcalls);
655 global.put_global(SymbolKey::from("x"), SymbolPrototype::Scalar(ExprType::Integer))?;
656
657 let mut local = global.enter_scope();
658 local.put_local(SymbolKey::from("x"), SymbolPrototype::Scalar(ExprType::Text))?;
659
660 let (reg, proto) = local.get_local_or_global(&VarRef::new("x", None))?;
661 assert_eq!(Register::local(0).unwrap(), reg);
662 assert_eq!(SymbolPrototype::Scalar(ExprType::Text), proto);
663
664 Ok(())
665 }
666
667 #[test]
668 fn test_local_falls_through_to_global() -> Result<()> {

Callers

nothing calls this directly

Calls 4

put_globalMethod · 0.80
enter_scopeMethod · 0.80
put_localMethod · 0.80
get_local_or_globalMethod · 0.80

Tested by

no test coverage detected