Is it a valid shader?

#version 120

varying vec2 uvf;

uniform sampler2D s1;
struct y{
sampler2D s2;
} z;

void main()
gl_FragColor = texture2D(z.s2,uvf);

This shader works on my 6600gt, but i wonder if it is valid to use a sampler as an l-value in assignment expression?

I suppose it is, it makes possible to choose between two samplers in some case. At less, it’s useful.

Id’s say it is invalid. you can’t have samples in a struct as samplers always have to be uniforms which can’t be in a struct either.

I used the GLSLValidate tool to verify correctnes. It is a good idea to use that tool as nvidia cards are way to tollerand and als0 accept malformed programs. Without GLSLValidate it is practically impossible to develop a shader which will also work on ATI without having an ATI card to test on.

[ | vector_math (3d math library) | software renderer ]

They say that GLSLValidate does not reflect glsl 1.2 features.

The 1.20 version of GLSL specification explicitly states:

Samplers cannot be treated as l-values; hence cannot be used as
out or inout function parameters, nor can they be assigned into.

That is true. GLSLValidate is 1.10 only.