@@ -1019,12 +1019,7 @@ function Base.getproperty(
10191019end 
10201020function  getvar (sys:: AbstractSystem , name:: Symbol ; namespace =  does_namespacing (sys))
10211021    systems =  get_systems (sys)
1022-     if  isdefined (sys, name)
1023-         Base. depwarn (
1024-             " `sys.name` like `sys.$name ` is deprecated. Use getters like `get_$name ` instead." 
1025-             " sys.$name " 
1026-         return  getfield (sys, name)
1027-     elseif  ! isempty (systems)
1022+     if  ! isempty (systems)
10281023        i =  findfirst (x ->  nameof (x) ==  name, systems)
10291024        if  i != =  nothing 
10301025            return  namespace ?  renamespace (sys, systems[i]) :  systems[i]
@@ -1079,19 +1074,14 @@ function getvar(sys::AbstractSystem, name::Symbol; namespace = does_namespacing(
10791074end 
10801075
10811076function  Base. setproperty! (sys:: AbstractSystem , prop:: Symbol , val)
1082-     #  We use this weird syntax because `parameters` and `unknowns` calls are
1083-     #  potentially expensive.
1084-     if  (params =  parameters (sys);
1085-     idx =  findfirst (s ->  getname (s) ==  prop, params);
1086-     idx != =  nothing )
1087-         get_defaults (sys)[params[idx]] =  value (val)
1088-     elseif  (sts =  unknowns (sys);
1089-     idx =  findfirst (s ->  getname (s) ==  prop, sts);
1090-     idx != =  nothing )
1091-         get_defaults (sys)[sts[idx]] =  value (val)
1092-     else 
1093-         setfield! (sys, prop, val)
1094-     end 
1077+     error (""" 
1078+     `setproperty!` on systems is invalid. Systems are immutable data structures, and \ 
1079+     modifications to fields should be made by constructing a new system. This can be done \ 
1080+     easily using packages such as Setfield.jl. 
1081+ 
1082+     If you are looking for the old behavior of updating the default of a variable via \ 
1083+     `setproperty!`, this should now be done by mutating `ModelingToolkit.get_defaults(sys)`. 
1084+     """  )
10951085end 
10961086
10971087apply_to_variables (f:: F , ex) where  {F} =  _apply_to_variables (f, ex)
0 commit comments