In-context Learning Generalizes, But Not Always Robustly: The Case of Syntax