Error message: Application of the irf function to a SVAR-model (time series analysis)

I estimated a structural autoregressive model with the following R commands:

#estimate VAR-model
var=VAR(dat, p=2)
#define A and B matrix
#estimate SVAR-model
svar=SVAR(x, Amat = A, Bmat = B)

When I try to calculate the impulse response functions with the R command:
the following error message appears:

Error in diag<-(*tmp*, value = 1) :
only matrix diagonals can be replaced

Can someone explain the error message to me?
How do I apply the irf function to a svar model?